@homebound/beam 2.205.0 → 2.207.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.
@@ -11,7 +11,7 @@ const utils_1 = require("../utils");
11
11
  const getInteractiveElement_1 = require("../utils/getInteractiveElement");
12
12
  const useTestIds_1 = require("../utils/useTestIds");
13
13
  function AvatarButton(props) {
14
- const { onClick: onPress, disabled, autoFocus, buttonRef, tooltip, menuTriggerProps, openInNew, ...avatarProps } = props;
14
+ const { onClick: onPress, disabled, autoFocus, buttonRef, tooltip, menuTriggerProps, openInNew, forceFocusStyles = false, ...avatarProps } = props;
15
15
  const isDisabled = !!disabled;
16
16
  const ariaProps = { onPress, isDisabled, autoFocus, ...menuTriggerProps };
17
17
  // eslint-disable-next-line react-hooks/rules-of-hooks
@@ -28,7 +28,7 @@ function AvatarButton(props) {
28
28
  ...resetStyles,
29
29
  ...(isHovered && exports.hoverStyles),
30
30
  ...(isPressed && exports.pressedStyles),
31
- ...(isFocusVisible && focusStyles),
31
+ ...(isFocusVisible || forceFocusStyles ? focusStyles : {}),
32
32
  ...(isDisabled && disabledStyles),
33
33
  }), [isHovered, isFocusVisible, isDisabled, isPressed]);
34
34
  const buttonAttrs = {
@@ -10,7 +10,7 @@ const utils_1 = require("../utils");
10
10
  const getInteractiveElement_1 = require("../utils/getInteractiveElement");
11
11
  const useTestIds_1 = require("../utils/useTestIds");
12
12
  function Button(props) {
13
- const { onClick: onPress, disabled, endAdornment, menuTriggerProps, tooltip, openInNew, download, contrast = false, ...otherProps } = props;
13
+ const { onClick: onPress, disabled, endAdornment, menuTriggerProps, tooltip, openInNew, download, contrast = false, forceFocusStyles = false, ...otherProps } = props;
14
14
  const asLink = typeof onPress === "string";
15
15
  const showExternalLinkIcon = (asLink && (0, utils_1.isAbsoluteUrl)(onPress)) || openInNew;
16
16
  const [asyncInProgress, setAsyncInProgress] = (0, react_1.useState)(false);
@@ -51,7 +51,7 @@ function Button(props) {
51
51
  ...(isHovered && !isPressed ? hoverStyles : {}),
52
52
  ...(isPressed ? pressedStyles : {}),
53
53
  ...(isDisabled || asyncInProgress ? { ...disabledStyles, ...Css_1.Css.cursorNotAllowed.$ } : {}),
54
- ...(isFocusVisible ? focusStyles : {}),
54
+ ...(isFocusVisible || forceFocusStyles ? focusStyles : {}),
55
55
  },
56
56
  ...tid,
57
57
  };
@@ -1,6 +1,6 @@
1
1
  import { IconProps } from "./Icon";
2
2
  import { OverlayTriggerProps } from "./internal/OverlayTrigger";
3
- interface ButtonMenuProps extends Pick<OverlayTriggerProps, "trigger" | "placement" | "disabled" | "tooltip"> {
3
+ interface ButtonMenuProps extends Pick<OverlayTriggerProps, "trigger" | "placement" | "disabled" | "tooltip" | "showActiveBorder"> {
4
4
  items: MenuItem[];
5
5
  persistentItems?: MenuItem[];
6
6
  defaultOpen?: boolean;
@@ -1,7 +1,7 @@
1
1
  import { ReactNode } from "react";
2
2
  import { OverlayTriggerProps } from "./internal/OverlayTrigger";
3
3
  import { ButtonVariant } from "./Button";
4
- export interface ButtonModalProps extends Pick<OverlayTriggerProps, "trigger" | "placement" | "disabled" | "tooltip"> {
4
+ export interface ButtonModalProps extends Pick<OverlayTriggerProps, "trigger" | "placement" | "disabled" | "tooltip" | "showActiveBorder"> {
5
5
  content: ReactNode;
6
6
  title?: string;
7
7
  variant?: ButtonVariant;
@@ -10,7 +10,7 @@ const utils_1 = require("../utils");
10
10
  const getInteractiveElement_1 = require("../utils/getInteractiveElement");
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, contrast = false, download = false, } = props;
13
+ const { onClick: onPress, disabled, color, icon, autoFocus, inc, buttonRef, tooltip, menuTriggerProps, openInNew, compact = false, contrast = false, download = false, forceFocusStyles = 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
@@ -27,7 +27,7 @@ function IconButton(props) {
27
27
  ...iconButtonStylesReset,
28
28
  ...(compact ? iconButtonCompact : iconButtonNormal),
29
29
  ...(isHovered && (contrast ? exports.iconButtonContrastStylesHover : exports.iconButtonStylesHover)),
30
- ...(isFocusVisible && iconButtonStylesFocus),
30
+ ...(isFocusVisible || forceFocusStyles ? iconButtonStylesFocus : {}),
31
31
  ...(isDisabled && iconButtonStylesDisabled),
32
32
  }), [isHovered, isFocusVisible, isDisabled, compact]);
33
33
  const iconColor = contrast ? contrastIconColor : defaultIconColor;
@@ -29,6 +29,7 @@ export interface OverlayTriggerProps {
29
29
  /** Prop set the style of the button element */
30
30
  variant?: ButtonVariant;
31
31
  hideEndAdornment?: boolean;
32
+ showActiveBorder?: boolean;
32
33
  }
33
34
  export declare function OverlayTrigger(props: OverlayTriggerProps): import("@emotion/react/jsx-runtime").JSX.Element;
34
35
  export declare function isTextButton(trigger: TextButtonTriggerProps | IconButtonTriggerProps | AvatarButtonTriggerProps): trigger is TextButtonTriggerProps;
@@ -13,7 +13,7 @@ const Css_1 = require("../../Css");
13
13
  const utils_1 = require("../../utils");
14
14
  const defaultTestId_1 = require("../../utils/defaultTestId");
15
15
  function OverlayTrigger(props) {
16
- const { trigger, buttonRef, menuTriggerProps, placement, state, disabled, tooltip, children, variant, hideEndAdornment, } = props;
16
+ const { trigger, buttonRef, menuTriggerProps, placement, state, disabled, tooltip, children, variant, hideEndAdornment, showActiveBorder = false } = props;
17
17
  const popoverRef = (0, react_1.useRef)(null);
18
18
  const { overlayProps: positionProps } = (0, react_aria_1.useOverlayPosition)({
19
19
  targetRef: buttonRef,
@@ -22,9 +22,10 @@ function OverlayTrigger(props) {
22
22
  isOpen: state.isOpen,
23
23
  onClose: state.close,
24
24
  placement: (placement ? `bottom ${placement}` : "bottom left"),
25
+ offset: showActiveBorder ? 4 : undefined,
25
26
  });
26
27
  const tid = (0, utils_1.useTestIds)(props, isTextButton(trigger) ? (0, defaultTestId_1.defaultTestId)(trigger.label) : isIconButton(trigger) ? trigger.icon : trigger.name);
27
- return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ css: Css_1.Css.relative.dib.$ }, { children: [isTextButton(trigger) ? ((0, jsx_runtime_1.jsx)(Button_1.Button, Object.assign({ variant: variant ? variant : "secondary" }, trigger, { menuTriggerProps: menuTriggerProps, buttonRef: buttonRef, endAdornment: !hideEndAdornment ? (0, jsx_runtime_1.jsx)(Icon_1.Icon, { icon: state.isOpen ? "chevronUp" : "chevronDown" }, void 0) : null, disabled: disabled, tooltip: tooltip, onClick: utils_1.noop }, tid), void 0)) : isIconButton(trigger) ? ((0, jsx_runtime_1.jsx)(IconButton_1.IconButton, Object.assign({}, trigger, { menuTriggerProps: menuTriggerProps, buttonRef: buttonRef }, tid, { disabled: disabled, tooltip: tooltip, onClick: utils_1.noop }), void 0)) : ((0, jsx_runtime_1.jsx)(AvatarButton_1.AvatarButton, Object.assign({}, trigger, { menuTriggerProps: menuTriggerProps, buttonRef: buttonRef }, tid, { disabled: disabled, tooltip: tooltip, onClick: utils_1.noop }), void 0)), state.isOpen && ((0, jsx_runtime_1.jsx)(internal_1.Popover, Object.assign({ triggerRef: buttonRef, popoverRef: popoverRef, positionProps: positionProps, onClose: () => state.close(), isOpen: state.isOpen }, { children: children }), void 0))] }), void 0));
28
+ return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ css: Css_1.Css.relative.dib.$ }, { children: [isTextButton(trigger) ? ((0, jsx_runtime_1.jsx)(Button_1.Button, Object.assign({ variant: variant ? variant : "secondary" }, trigger, { menuTriggerProps: menuTriggerProps, buttonRef: buttonRef, endAdornment: !hideEndAdornment ? (0, jsx_runtime_1.jsx)(Icon_1.Icon, { icon: state.isOpen ? "chevronUp" : "chevronDown" }, void 0) : null, disabled: disabled, tooltip: tooltip, onClick: utils_1.noop, forceFocusStyles: showActiveBorder && state.isOpen }, tid), void 0)) : isIconButton(trigger) ? ((0, jsx_runtime_1.jsx)(IconButton_1.IconButton, Object.assign({}, trigger, { menuTriggerProps: menuTriggerProps, buttonRef: buttonRef }, tid, { disabled: disabled, tooltip: tooltip, onClick: utils_1.noop, forceFocusStyles: showActiveBorder && state.isOpen }), void 0)) : ((0, jsx_runtime_1.jsx)(AvatarButton_1.AvatarButton, Object.assign({}, trigger, { menuTriggerProps: menuTriggerProps, buttonRef: buttonRef }, tid, { disabled: disabled, tooltip: tooltip, onClick: utils_1.noop, forceFocusStyles: showActiveBorder && state.isOpen }), void 0)), state.isOpen && ((0, jsx_runtime_1.jsx)(internal_1.Popover, Object.assign({ triggerRef: buttonRef, popoverRef: popoverRef, positionProps: positionProps, onClose: () => state.close(), isOpen: state.isOpen }, { children: children }), void 0))] }), void 0));
28
29
  }
29
30
  exports.OverlayTrigger = OverlayTrigger;
30
31
  function isTextButton(trigger) {
@@ -17,12 +17,12 @@ function Popover(props) {
17
17
  // By returning `false` in this function it will no longer call `stopPropagation`, but it also will not call `onHide` for us, so we need to call `onClose` ourselves.
18
18
  var _a;
19
19
  // If we clicked the trigger element (or within it), then that will call a `state.toggle` for us.
20
- // Return early if that happens, otherwise we'd call `onClose`, then the trigger would toggle it back open.
20
+ // Return early if that happens.
21
21
  if ((_a = triggerRef.current) === null || _a === void 0 ? void 0 : _a.contains(e)) {
22
22
  return true;
23
23
  }
24
- onClose();
25
- return false;
24
+ //Do not close the Popover if the user is interacting with a tribute menu, dialog or alert on top of it, otherwise close it.
25
+ return !(e.closest(".tribute-container") || e.closest("[role='dialog']") || e.closest("[role='alert']"));
26
26
  },
27
27
  ...others,
28
28
  }, popoverRef);
@@ -1,6 +1,6 @@
1
1
  import { ReactNode } from "react";
2
2
  interface StaticFieldProps {
3
- label: string;
3
+ label: ReactNode;
4
4
  value?: string;
5
5
  children?: ReactNode;
6
6
  }
@@ -8,7 +8,7 @@ const defaultTestId_1 = require("../utils/defaultTestId");
8
8
  const useTestIds_1 = require("../utils/useTestIds");
9
9
  function StaticField(props) {
10
10
  const { label, value, children } = props;
11
- const tid = (0, useTestIds_1.useTestIds)(props, (0, defaultTestId_1.defaultTestId)(label));
11
+ const tid = (0, useTestIds_1.useTestIds)(props, typeof label === "string" ? (0, defaultTestId_1.defaultTestId)(label) : "staticField");
12
12
  const id = (0, utils_1.useId)();
13
13
  return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("label", Object.assign({ css: Css_1.Css.db.sm.gray700.mbPx(4).$, htmlFor: id }, tid.label, { children: label }), void 0), (0, jsx_runtime_1.jsx)("div", Object.assign({ id: id, css: Css_1.Css.smMd.gray900.df.aic.$ }, tid, { children: value || children }), void 0)] }, void 0));
14
14
  }
@@ -6,6 +6,7 @@ import { Xss } from "./Css";
6
6
  export interface BeamFocusableProps {
7
7
  /** Whether the element should receive focus on render. */
8
8
  autoFocus?: boolean;
9
+ forceFocusStyles?: boolean;
9
10
  }
10
11
  export interface BeamButtonProps {
11
12
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.205.0",
3
+ "version": "2.207.0",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",