@homebound/beam 2.173.0 → 2.175.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.
@@ -3,6 +3,7 @@ declare type ChipType = "caution" | "warning" | "success" | "light" | "dark" | "
3
3
  export declare const ChipTypes: Record<ChipType, ChipType>;
4
4
  export interface ChipProps<X> {
5
5
  text: string;
6
+ title?: string;
6
7
  xss?: X;
7
8
  type?: ChipType;
8
9
  }
@@ -16,7 +16,7 @@ exports.ChipTypes = {
16
16
  };
17
17
  /** Kinda like a chip, but read-only, so no `onClick` or `hover`. */
18
18
  function Chip({ type = exports.ChipTypes.neutral, ...props }) {
19
- const { text, xss = {} } = props;
19
+ const { text, title = text, xss = {} } = props;
20
20
  const { fieldProps } = (0, PresentationContext_1.usePresentationContext)();
21
21
  const compact = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.compact;
22
22
  const tid = (0, useTestIds_1.useTestIds)(props, "chip");
@@ -24,7 +24,7 @@ function Chip({ type = exports.ChipTypes.neutral, ...props }) {
24
24
  ...Css_1.Css[compact ? "xs" : "sm"].dif.aic.br16.pl1.px1.pyPx(2).gray900.$,
25
25
  ...typeStyles[type],
26
26
  ...xss,
27
- } }, tid, { title: text }, { children: (0, jsx_runtime_1.jsx)("span", Object.assign({ css: Css_1.Css.lineClamp1.breakAll.$ }, { children: text }), void 0) }), void 0));
27
+ } }, tid, { title: title }, { children: (0, jsx_runtime_1.jsx)("span", Object.assign({ css: Css_1.Css.lineClamp1.breakAll.$ }, { children: text }), void 0) }), void 0));
28
28
  }
29
29
  exports.Chip = Chip;
30
30
  const typeStyles = {
@@ -1,7 +1,11 @@
1
1
  import { Margin, Only, Xss } from "../Css";
2
2
  declare type ChipsXss = Xss<Margin>;
3
+ export interface ChipValue {
4
+ text: string;
5
+ title: string;
6
+ }
3
7
  export interface ChipsProps<X> {
4
- values: string[];
8
+ values: string[] | ChipValue[];
5
9
  xss?: X;
6
10
  }
7
11
  /** Renders a list of `Chip`s, with wrapping & appropriate margin between each `Chip`. */
@@ -13,6 +13,9 @@ function Chips(props) {
13
13
  ...Css_1.Css.df.aifs.gap1.whiteSpace("normal").$,
14
14
  ...(wrap !== false ? Css_1.Css.add({ flexWrap: "wrap" }).$ : {}),
15
15
  ...xss,
16
- } }, { children: values.map((value, i) => ((0, jsx_runtime_1.jsx)(Chip_1.Chip, { text: value }, i))) }), void 0));
16
+ } }, { children: values.map((value, i) => {
17
+ const { text, title } = (value.hasOwnProperty("text") ? value : { text: value });
18
+ return (0, jsx_runtime_1.jsx)(Chip_1.Chip, { text: text, title: title }, i);
19
+ }) }), void 0));
17
20
  }
18
21
  exports.Chips = Chips;
@@ -22,7 +22,7 @@ function ScrollableContent(props) {
22
22
  if (!scrollableEl) {
23
23
  return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children }, void 0);
24
24
  }
25
- return (0, react_dom_1.createPortal)(!virtualized ? (children) : (
25
+ return (0, react_dom_1.createPortal)(!virtualized ? ((0, jsx_runtime_1.jsx)("div", Object.assign({ css: ScrollableParent_1.scrollContainerBottomPadding }, { children: children }), void 0)) : (
26
26
  // To prevent Virtuoso's scrollbar from being set in based on the Layout's padding, we will use the FullBleed component w/o padding to push it back over
27
27
  (0, jsx_runtime_1.jsx)(FullBleed_1.FullBleed, Object.assign({ omitPadding: true }, { children: (0, jsx_runtime_1.jsx)("div", Object.assign({ css: Css_1.Css.h100.pl(pl).$ }, { children: children }), void 0) }), void 0)), scrollableEl);
28
28
  }
@@ -12,4 +12,11 @@ interface ScrollableParentContextProviderProps {
12
12
  }
13
13
  export declare function ScrollableParent(props: PropsWithChildren<ScrollableParentContextProviderProps>): import("@emotion/react/jsx-runtime").JSX.Element;
14
14
  export declare function useScrollableParent(): ScrollableParentContextProps;
15
+ export declare const scrollContainerBottomPadding: {
16
+ height: import("csstype").Property.Height<0 | (string & {})> | undefined;
17
+ } & {
18
+ content: import("csstype").Property.Content | undefined;
19
+ } & {
20
+ display: import("csstype").Property.Display | undefined;
21
+ };
15
22
  export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useScrollableParent = exports.ScrollableParent = void 0;
3
+ exports.scrollContainerBottomPadding = exports.useScrollableParent = exports.ScrollableParent = void 0;
4
4
  const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const Css_1 = require("../../Css");
@@ -31,10 +31,15 @@ function ScrollableParent(props) {
31
31
  (0, react_1.useEffect)(() => {
32
32
  scrollableRef.current.appendChild(scrollableEl);
33
33
  }, [scrollableEl]);
34
- return ((0, jsx_runtime_1.jsx)(ScrollableParentContext.Provider, Object.assign({ value: context }, { children: (0, jsx_runtime_1.jsxs)(Tag, Object.assign({ css: { ...Css_1.Css.mh0.mw0.fg1.df.fdc.$, ...otherXss } }, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ css: Css_1.Css.pl(context.pl).pr(context.pr).if(!hasScrollableContent).h100.overflowAuto.$ }, { children: children }), void 0), (0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.fg1.overflowAuto.pl(context.pl).pr(context.pr).$, ref: scrollableRef }, void 0)] }), void 0) }), void 0));
34
+ return ((0, jsx_runtime_1.jsx)(ScrollableParentContext.Provider, Object.assign({ value: context }, { children: (0, jsx_runtime_1.jsxs)(Tag, Object.assign({ css: { ...Css_1.Css.mh0.mw0.fg1.df.fdc.$, ...otherXss } }, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ css: {
35
+ ...Css_1.Css.pl(context.pl).pr(context.pr),
36
+ ...(!hasScrollableContent ? { ...Css_1.Css.overflowAuto.$, ...exports.scrollContainerBottomPadding } : undefined),
37
+ } }, { children: children }), void 0), (0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.fg1.overflowAuto.pl(context.pl).pr(context.pr).$, ref: scrollableRef }, void 0)] }), void 0) }), void 0));
35
38
  }
36
39
  exports.ScrollableParent = ScrollableParent;
37
40
  function useScrollableParent() {
38
41
  return (0, react_1.useContext)(ScrollableParentContext);
39
42
  }
40
43
  exports.useScrollableParent = useScrollableParent;
44
+ // Styles to wrap around the scrollable content in order to give padding beneath the content within the scrollable container.
45
+ exports.scrollContainerBottomPadding = Css_1.Css.h100.addIn("&:after", Css_1.Css.contentEmpty.db.h2.$).$;
@@ -32,14 +32,20 @@ function useSetupColumnSizes(style, columns, resizeRef) {
32
32
  const calculateImmediately = (0, react_1.useRef)(true);
33
33
  const [tableWidth, setTableWidth] = (0, react_1.useState)();
34
34
  // Calc our initial/first render sizes where we won't have a width yet
35
- const [columnSizes, setColumnSizes] = (0, react_1.useState)(
36
- // TODO Add a useEffect to re-calc this on change
37
- (0, GridTable_1.calcColumnSizes)(columns, (_a = style.nestedCards) === null || _a === void 0 ? void 0 : _a.firstLastColumnWidth, tableWidth, style.minWidthPx));
35
+ const [columnSizes, setColumnSizes] = (0, react_1.useState)((0, GridTable_1.calcColumnSizes)(columns, (_a = style.nestedCards) === null || _a === void 0 ? void 0 : _a.firstLastColumnWidth, tableWidth, style.minWidthPx));
38
36
  const setTableAndColumnWidths = (0, react_1.useCallback)((width) => {
39
37
  var _a;
40
38
  setTableWidth(width);
41
39
  setColumnSizes((0, GridTable_1.calcColumnSizes)(columns, (_a = style.nestedCards) === null || _a === void 0 ? void 0 : _a.firstLastColumnWidth, width, style.minWidthPx));
42
40
  }, [setTableWidth, setColumnSizes, columns, style]);
41
+ // Used to recalculate our columns sizes when columns change
42
+ (0, react_1.useEffect)(() => {
43
+ var _a;
44
+ if (!calculateImmediately.current) {
45
+ const width = (_a = resizeRef.current) === null || _a === void 0 ? void 0 : _a.clientWidth;
46
+ width && setTableAndColumnWidths(width);
47
+ }
48
+ }, [columns, setTableAndColumnWidths]);
43
49
  const setTableAndColumnWidthsDebounced = (0, use_debounce_1.useDebouncedCallback)(setTableAndColumnWidths, 100);
44
50
  const onResize = (0, react_1.useCallback)(() => {
45
51
  const target = resizeRef.current;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.173.0",
3
+ "version": "2.175.0",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",