@homebound/beam 2.105.2 → 2.105.3

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.
@@ -2,13 +2,15 @@ import { ReactElement, ReactNode } from "react";
2
2
  interface TooltipProps {
3
3
  /** The content that shows up when hovered */
4
4
  title: ReactNode;
5
- children: ReactElement;
5
+ children: ReactNode;
6
6
  placement?: Placement;
7
7
  delay?: number;
8
8
  disabled?: boolean;
9
9
  }
10
10
  export declare function Tooltip(props: TooltipProps): import("@emotion/react/jsx-runtime").JSX.Element;
11
11
  export declare type Placement = "top" | "bottom" | "left" | "right" | "auto";
12
- export declare function maybeTooltip(props: TooltipProps): import("@emotion/react/jsx-runtime").JSX.Element;
12
+ export declare function maybeTooltip(props: Omit<TooltipProps, "children"> & {
13
+ children: ReactElement;
14
+ }): import("@emotion/react/jsx-runtime").JSX.Element;
13
15
  export declare function resolveTooltip(disabled?: boolean | ReactNode, tooltip?: ReactNode, readOnly?: boolean | ReactNode): ReactNode | undefined;
14
16
  export {};
@@ -27,13 +27,15 @@ const react_dom_1 = require("react-dom");
27
27
  const react_popper_1 = require("react-popper");
28
28
  const react_stately_1 = require("react-stately");
29
29
  const Css_1 = require("../Css");
30
+ const utils_1 = require("../utils");
30
31
  function Tooltip(props) {
31
32
  const { placement, children, title, disabled, delay = 0 } = props;
32
33
  const state = (0, react_stately_1.useTooltipTriggerState)({ delay, isDisabled: disabled });
33
34
  const triggerRef = react_1.default.useRef(null);
34
35
  const { triggerProps, tooltipProps: _tooltipProps } = (0, react_aria_1.useTooltipTrigger)({ isDisabled: disabled }, state, triggerRef);
35
36
  const { tooltipProps } = (0, react_aria_1.useTooltip)(_tooltipProps, state);
36
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", Object.assign({ ref: triggerRef }, triggerProps, { children: children }), void 0), state.isOpen && ((0, jsx_runtime_1.jsx)(Popper, Object.assign({}, (0, react_aria_1.mergeProps)(_tooltipProps, tooltipProps), { triggerRef: triggerRef, content: title, placement: placement }), void 0))] }, void 0));
37
+ const tid = (0, utils_1.useTestIds)(props, "tooltip");
38
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", Object.assign({ ref: triggerRef }, triggerProps, (!state.isOpen && typeof title === "string" ? { title } : {}), tid, { children: children }), void 0), state.isOpen && ((0, jsx_runtime_1.jsx)(Popper, Object.assign({}, (0, react_aria_1.mergeProps)(_tooltipProps, tooltipProps), { triggerRef: triggerRef, content: title, placement: placement }), void 0))] }, void 0));
37
39
  }
38
40
  exports.Tooltip = Tooltip;
39
41
  function Popper({ triggerRef, content, placement = "auto" }) {
@@ -49,6 +51,7 @@ function Popper({ triggerRef, content, placement = "auto" }) {
49
51
  return (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsxs)("div", Object.assign({ ref: popperRef, style: styles.popper }, attributes.popper, { css: Css_1.Css.maxw("320px").bgGray900.white.px1.py("4px").br4.xs.z999.$ }, { children: [(0, jsx_runtime_1.jsx)("div", { ref: setArrowRef, style: { ...styles.arrow }, id: "arrow" }, void 0), content] }), void 0), document.body);
50
52
  }
51
53
  // Helper function to conditionally wrap component with Tooltip if necessary.
54
+ // `maybeTooltip` requires that the `children` prop be a ReactElement, even though <Tooltip /> allows for ReactNode.
52
55
  function maybeTooltip(props) {
53
56
  return props.title ? (0, jsx_runtime_1.jsx)(Tooltip, Object.assign({}, props), void 0) : props.children;
54
57
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.105.2",
3
+ "version": "2.105.3",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",