@homebound/beam 2.355.0 → 2.356.1

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.
@@ -326,6 +326,7 @@ function renderDiv(style, id, columns, visibleDataRows, keptSelectedRows, firstR
326
326
  function renderTable(style, id, columns, visibleDataRows, keptSelectedRows, firstRowMessage, stickyHeader, xss, _virtuosoRef, tableHeadRows, stickyOffset, _infiniteScroll) {
327
327
  return ((0, jsx_runtime_1.jsxs)("table", { css: {
328
328
  ...Css_1.Css.w100.add("borderCollapse", "separate").add("borderSpacing", "0").$,
329
+ ...Css_1.Css.addIn("& tr ", { pageBreakAfter: "auto", pageBreakInside: "avoid" }).$,
329
330
  ...Css_1.Css.addIn("& > tbody > tr > * ", style.betweenRowsCss || {})
330
331
  // removes border between header and second row
331
332
  .addIn("& > tbody > tr:first-of-type", style.firstNonHeaderRowCss || {}).$,
@@ -1,13 +1,17 @@
1
1
  import { IconKey } from "./";
2
2
  import { Margin, Only, Xss } from "../Css";
3
+ import { ReactNode } from "react";
3
4
  type TagXss = Margin | "backgroundColor" | "color";
4
5
  export type TagType = "info" | "caution" | "warning" | "success" | "neutral";
5
6
  interface TagProps<X> {
6
- text: string;
7
+ text: ReactNode;
7
8
  type?: TagType;
8
9
  xss?: X;
9
10
  icon?: IconKey;
11
+ /** A tooltip will automatically be displayed if the text is truncated. Set to true to prevent this behavior.
12
+ * @default false */
13
+ preventTooltip?: boolean;
10
14
  }
11
15
  /** Tag used for indicating a status */
12
- export declare function Tag<X extends Only<Xss<TagXss>, X>>({ text, type, xss, ...otherProps }: TagProps<X>): import("@emotion/react/jsx-runtime").JSX.Element;
16
+ export declare function Tag<X extends Only<Xss<TagXss>, X>>(props: TagProps<X>): import("@emotion/react/jsx-runtime").JSX.Element;
13
17
  export {};
@@ -5,11 +5,27 @@ const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
5
5
  const components_1 = require("./");
6
6
  const Css_1 = require("../Css");
7
7
  const utils_1 = require("../utils");
8
+ const react_1 = require("react");
9
+ const utils_2 = require("@react-aria/utils");
8
10
  /** Tag used for indicating a status */
9
- function Tag({ text, type, xss, ...otherProps }) {
11
+ function Tag(props) {
12
+ const { text, type, xss, preventTooltip = false, ...otherProps } = props;
10
13
  const typeStyles = getStyles(type);
11
14
  const tid = (0, utils_1.useTestIds)(otherProps);
12
- return ((0, jsx_runtime_1.jsxs)("span", { ...tid, css: { ...Css_1.Css.dif.tinySb.ttu.aic.gapPx(4).pxPx(6).pyPx(2).gray900.br4.$, ...typeStyles, ...xss }, title: text, children: [otherProps.icon && ((0, jsx_runtime_1.jsx)("span", { css: Css_1.Css.fs0.$, children: (0, jsx_runtime_1.jsx)(components_1.Icon, { icon: otherProps.icon, inc: 1.5 }) })), (0, jsx_runtime_1.jsx)("span", { css: Css_1.Css.lineClamp1.wbba.$, children: text })] }));
15
+ const [showTooltip, setShowTooltip] = (0, react_1.useState)(false);
16
+ const ref = (0, react_1.useRef)(null);
17
+ (0, utils_2.useResizeObserver)({
18
+ ref,
19
+ onResize: () => {
20
+ if (ref.current) {
21
+ setShowTooltip(ref.current.offsetHeight < ref.current.scrollHeight);
22
+ }
23
+ },
24
+ });
25
+ return (0, components_1.maybeTooltip)({
26
+ title: !preventTooltip && showTooltip ? text : undefined,
27
+ children: ((0, jsx_runtime_1.jsxs)("span", { ...tid, css: { ...Css_1.Css.dif.tinySb.ttu.aic.gapPx(4).pxPx(6).pyPx(2).gray900.br4.$, ...typeStyles, ...xss }, children: [otherProps.icon && ((0, jsx_runtime_1.jsx)("span", { css: Css_1.Css.fs0.$, children: (0, jsx_runtime_1.jsx)(components_1.Icon, { icon: otherProps.icon, inc: 1.5 }) })), (0, jsx_runtime_1.jsx)("span", { ref: ref, css: Css_1.Css.lineClamp1.wbba.$, children: text })] })),
28
+ });
13
29
  }
14
30
  exports.Tag = Tag;
15
31
  function getStyles(type) {
@@ -1,4 +1,5 @@
1
1
  import { ReactNode } from "react";
2
+ import { Palette } from "../Css";
2
3
  interface TooltipProps {
3
4
  /** The content that shows up when hovered */
4
5
  title: ReactNode;
@@ -6,6 +7,7 @@ interface TooltipProps {
6
7
  placement?: Placement;
7
8
  delay?: number;
8
9
  disabled?: boolean;
10
+ bgColor?: Palette;
9
11
  }
10
12
  export declare function Tooltip(props: TooltipProps): import("@emotion/react/jsx-runtime").JSX.Element;
11
13
  export type Placement = "top" | "bottom" | "left" | "right" | "auto";
@@ -10,7 +10,7 @@ const react_stately_1 = require("react-stately");
10
10
  const Css_1 = require("../Css");
11
11
  const utils_1 = require("../utils");
12
12
  function Tooltip(props) {
13
- const { placement, children, title, disabled, delay = 0 } = props;
13
+ const { placement, children, title, disabled, delay = 0, bgColor } = props;
14
14
  const state = (0, react_stately_1.useTooltipTriggerState)({ delay, isDisabled: disabled });
15
15
  const triggerRef = (0, react_1.useRef)(null);
16
16
  const { triggerProps, tooltipProps: _tooltipProps } = (0, react_aria_1.useTooltipTrigger)({ isDisabled: disabled }, state, triggerRef);
@@ -24,10 +24,10 @@ function Tooltip(props) {
24
24
  // This is due to some code in React-Aria that prevents default due ot mobile browser inconsistencies,
25
25
  // and the only way they don't prevent default is if the element is draggable.
26
26
  // See https://github.com/adobe/react-spectrum/discussions/3058 for discussion related to this issue.
27
- draggable: true, onDragStart: (e) => e.preventDefault(), children: children }), state.isOpen && ((0, jsx_runtime_1.jsx)(Popper, { ...(0, react_aria_1.mergeProps)(_tooltipProps, tooltipProps), triggerRef: triggerRef, content: title, placement: placement }))] }));
27
+ draggable: true, onDragStart: (e) => e.preventDefault(), children: children }), state.isOpen && ((0, jsx_runtime_1.jsx)(Popper, { ...(0, react_aria_1.mergeProps)(_tooltipProps, tooltipProps), triggerRef: triggerRef, content: title, placement: placement, bgColor: bgColor }))] }));
28
28
  }
29
29
  exports.Tooltip = Tooltip;
30
- function Popper({ triggerRef, content, placement = "auto" }) {
30
+ function Popper({ triggerRef, content, placement = "auto", bgColor = Css_1.Palette.Gray900 }) {
31
31
  var _a;
32
32
  const popperRef = (0, react_1.useRef)(null);
33
33
  const [arrowRef, setArrowRef] = (0, react_1.useState)(null);
@@ -42,7 +42,7 @@ function Popper({ triggerRef, content, placement = "auto" }) {
42
42
  ],
43
43
  placement,
44
44
  });
45
- return (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsxs)("div", { ref: popperRef, style: styles.popper, ...attributes.popper, css: Css_1.Css.maxw("320px").bgGray900.white.px1.py("4px").br4.xs.add("zIndex", 999999).$, children: [(0, jsx_runtime_1.jsx)("div", { ref: setArrowRef, style: { ...styles.arrow }, id: "arrow" }), content] }), document.body);
45
+ return (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsxs)("div", { ref: popperRef, style: styles.popper, ...attributes.popper, css: Css_1.Css.maxw("320px").bgColor(bgColor).bshBasic.white.px1.py("4px").br4.xs.add("zIndex", 999999).$, children: [(0, jsx_runtime_1.jsx)("div", { ref: setArrowRef, style: { ...styles.arrow }, id: "arrow" }), content] }), document.body);
46
46
  }
47
47
  // Helper function to conditionally wrap component with Tooltip if necessary.
48
48
  function maybeTooltip(props) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.355.0",
3
+ "version": "2.356.1",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",