@homebound/beam 2.265.0 → 2.266.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.
@@ -1,9 +1,11 @@
1
+ import { ReactNode } from "react";
1
2
  import { GridColumnWithId, Kinded, RenderAs } from "../types";
2
3
  interface ExpandableHeaderProps<R extends Kinded> {
3
4
  title: string;
4
5
  column: GridColumnWithId<R>;
5
6
  minStickyLeftOffset: number;
6
7
  as: RenderAs;
8
+ tooltipEl?: ReactNode;
7
9
  }
8
10
  export declare function ExpandableHeader<R extends Kinded>(props: ExpandableHeaderProps<R>): import("@emotion/react/jsx-runtime").JSX.Element;
9
11
  export {};
@@ -11,7 +11,7 @@ const hooks_1 = require("../../../hooks");
11
11
  const utils_2 = require("../../../utils");
12
12
  const Loader_1 = require("../../Loader");
13
13
  function ExpandableHeader(props) {
14
- const { title, column, minStickyLeftOffset, as } = props;
14
+ const { title, column, minStickyLeftOffset, as, tooltipEl } = props;
15
15
  const { tableState } = (0, react_1.useContext)(TableState_1.TableStateContext);
16
16
  const expandedColumnIds = (0, hooks_1.useComputed)(() => tableState.expandedColumnIds, [tableState]);
17
17
  const isExpanded = expandedColumnIds.includes(column.id);
@@ -27,10 +27,10 @@ function ExpandableHeader(props) {
27
27
  }
28
28
  // manually calling this as loadExpandedColumns does not toggle
29
29
  tableState.toggleExpandedColumn(column.id);
30
- }, "data-testid": "expandableColumn", children: [(0, jsx_runtime_1.jsx)("span", { css: Css_1.Css.tl.lineClamp2
30
+ }, "data-testid": "expandableColumn", children: [(0, jsx_runtime_1.jsxs)("span", { css: Css_1.Css.df.aic
31
31
  .if(applyStickyStyles)
32
32
  .sticky.leftPx(minStickyLeftOffset + 12)
33
33
  .pr2.mr2.bgWhite.z(utils_1.zIndices.expandableHeaderTitle)
34
- .if(isHovered).bgGray100.$, children: title }), (0, jsx_runtime_1.jsx)("span", { css: Css_1.Css.if(applyStickyStyles).sticky.rightPx(12).z(utils_1.zIndices.expandableHeaderIcon).$, children: isLoading ? (0, jsx_runtime_1.jsx)(Loader_1.Loader, { size: "xs" }) : (0, jsx_runtime_1.jsx)(Icon_1.Icon, { icon: isExpanded ? "chevronLeft" : "chevronRight", inc: 2 }) })] }));
34
+ .if(isHovered).bgGray100.$, children: [(0, jsx_runtime_1.jsx)("span", { css: Css_1.Css.tl.lineClamp2.$, children: title }), tooltipEl] }), (0, jsx_runtime_1.jsx)("span", { css: Css_1.Css.if(applyStickyStyles).sticky.rightPx(12).z(utils_1.zIndices.expandableHeaderIcon).$, children: isLoading ? (0, jsx_runtime_1.jsx)(Loader_1.Loader, { size: "xs" }) : (0, jsx_runtime_1.jsx)(Icon_1.Icon, { icon: isExpanded ? "chevronLeft" : "chevronRight", inc: 2 }) })] }));
35
35
  }
36
36
  exports.ExpandableHeader = ExpandableHeader;
@@ -1,9 +1,11 @@
1
+ import { ReactNode } from "react";
1
2
  import { Properties } from "../../../Css";
2
3
  interface SortHeaderProps {
3
4
  content: string;
4
5
  xss?: Properties;
5
6
  iconOnLeft?: boolean;
6
7
  sortKey: string;
8
+ tooltipEl?: ReactNode;
7
9
  }
8
10
  /**
9
11
  * Wraps column header names with up/down sorting icons.
@@ -20,7 +20,7 @@ const useTestIds_1 = require("../../../utils/useTestIds");
20
20
  * current sort state + `toggleSort` function
21
21
  */
22
22
  function SortHeader(props) {
23
- const { content, xss, iconOnLeft = false, sortKey } = props;
23
+ const { content, xss, iconOnLeft = false, sortKey, tooltipEl } = props;
24
24
  const { isHovered, hoverProps } = (0, hooks_1.useHover)({});
25
25
  const { tableState } = (0, react_1.useContext)(TableState_1.TableStateContext);
26
26
  const current = (0, hooks_1.useComputed)(() => { var _a; return (_a = tableState.sortState) === null || _a === void 0 ? void 0 : _a.current; }, [tableState]);
@@ -33,6 +33,6 @@ function SortHeader(props) {
33
33
  .if(isHovered || sorted !== undefined)
34
34
  .visibility("visible").$,
35
35
  }, inc: 2, ...tid.icon }) }));
36
- return ((0, jsx_runtime_1.jsxs)("div", { ...tid, css: { ...Css_1.Css.df.aic.h100.cursorPointer.selectNone.$, ...xss }, ...hoverProps, onClick: toggleSort, children: [iconOnLeft && icon, (0, jsx_runtime_1.jsx)("span", { css: Css_1.Css.lineClamp2.$, children: content }), !iconOnLeft && icon] }));
36
+ return ((0, jsx_runtime_1.jsxs)("div", { ...tid, css: { ...Css_1.Css.df.aic.h100.cursorPointer.selectNone.$, ...xss }, ...hoverProps, onClick: toggleSort, children: [iconOnLeft && icon, (0, jsx_runtime_1.jsx)("span", { css: Css_1.Css.lineClamp2.$, children: content }), tooltipEl, !iconOnLeft && icon] }));
37
37
  }
38
38
  exports.SortHeader = SortHeader;
@@ -5,12 +5,11 @@ const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
5
5
  const react_router_dom_1 = require("react-router-dom");
6
6
  const CssReset_1 = require("../../CssReset");
7
7
  const TableStyles_1 = require("../TableStyles");
8
- const Tooltip_1 = require("../../Tooltip");
9
8
  const Css_1 = require("../../../Css");
10
9
  /** Renders our default cell element, i.e. if no row links and no custom renderCell are used. */
11
10
  const defaultRenderFn = (as) => (key, css, content, row, rowStyle, classNames, onClick, tooltip) => {
12
11
  const Cell = as === "table" ? "td" : "div";
13
- return ((0, jsx_runtime_1.jsx)(Cell, { css: { ...css, ...(0, TableStyles_1.tableRowStyles)(as) }, className: classNames, onClick: onClick, children: (0, Tooltip_1.maybeTooltip)({ title: tooltip, placement: "top", children: content }) }, key));
12
+ return ((0, jsx_runtime_1.jsx)(Cell, { css: { ...css, ...(0, TableStyles_1.tableRowStyles)(as) }, className: classNames, onClick: onClick, children: content }, key));
14
13
  };
15
14
  exports.defaultRenderFn = defaultRenderFn;
16
15
  /**
@@ -19,24 +18,16 @@ exports.defaultRenderFn = defaultRenderFn;
19
18
  * */
20
19
  const headerRenderFn = (column, as, colSpan) => (key, css, content, row, rowStyle, classNames, onClick, tooltip) => {
21
20
  const Cell = as === "table" ? "th" : "div";
22
- return ((0, jsx_runtime_1.jsx)(Cell, { css: { ...css, ...(0, TableStyles_1.tableRowStyles)(as, column) }, className: classNames, ...(as === "table" && { colSpan }), children: (0, Tooltip_1.maybeTooltip)({ title: tooltip, placement: "top", children: content }) }, key));
21
+ return ((0, jsx_runtime_1.jsx)(Cell, { css: { ...css, ...(0, TableStyles_1.tableRowStyles)(as, column) }, className: classNames, ...(as === "table" && { colSpan }), children: content }, key));
23
22
  };
24
23
  exports.headerRenderFn = headerRenderFn;
25
24
  /** Renders a cell element when a row link is in play. */
26
25
  const rowLinkRenderFn = (as) => (key, css, content, row, rowStyle, classNames, onClick, tooltip) => {
27
26
  const to = rowStyle.rowLink(row);
28
27
  if (as === "table") {
29
- return ((0, jsx_runtime_1.jsx)("td", { css: { ...css, ...(0, TableStyles_1.tableRowStyles)(as) }, className: classNames, children: (0, Tooltip_1.maybeTooltip)({
30
- title: tooltip,
31
- placement: "top",
32
- children: ((0, jsx_runtime_1.jsx)(react_router_dom_1.Link, { to: to, css: Css_1.Css.noUnderline.color("unset").db.$, className: CssReset_1.navLink, children: content })),
33
- }) }, key));
28
+ return ((0, jsx_runtime_1.jsx)("td", { css: { ...css, ...(0, TableStyles_1.tableRowStyles)(as) }, className: classNames, children: (0, jsx_runtime_1.jsx)(react_router_dom_1.Link, { to: to, css: Css_1.Css.noUnderline.color("unset").db.$, className: CssReset_1.navLink, children: content }) }, key));
34
29
  }
35
- return (0, Tooltip_1.maybeTooltip)({
36
- title: tooltip,
37
- placement: "top",
38
- children: ((0, jsx_runtime_1.jsx)(react_router_dom_1.Link, { to: to, css: { ...Css_1.Css.noUnderline.color("unset").$, ...css }, className: `${CssReset_1.navLink} ${classNames}`, children: content }, key)),
39
- });
30
+ return ((0, jsx_runtime_1.jsx)(react_router_dom_1.Link, { to: to, css: { ...Css_1.Css.noUnderline.color("unset").$, ...css }, className: `${CssReset_1.navLink} ${classNames}`, children: content }, key));
40
31
  };
41
32
  exports.rowLinkRenderFn = rowLinkRenderFn;
42
33
  /** Renders a cell that will fire the RowStyle.onClick. */
@@ -45,6 +36,6 @@ const rowClickRenderFn = (as, api) => (key, css, content, row, rowStyle, classNa
45
36
  return ((0, jsx_runtime_1.jsx)(Cell, { ...{ key }, css: { ...css, ...(0, TableStyles_1.tableRowStyles)(as) }, className: classNames, onClick: (e) => {
46
37
  rowStyle.onClick(row, api);
47
38
  onClick && onClick();
48
- }, children: (0, Tooltip_1.maybeTooltip)({ title: tooltip, placement: "top", children: content }) }));
39
+ }, children: content }));
49
40
  };
50
41
  exports.rowClickRenderFn = rowClickRenderFn;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.zIndices = exports.reservedRowKinds = exports.EXPANDABLE_HEADER = exports.TOTALS = exports.HEADER = exports.matchesFilter = exports.maybeApplyFunction = exports.getJustification = exports.getAlignment = exports.getFirstOrLastCellCss = exports.getIndentationCss = exports.emptyCell = exports.DESC = exports.ASC = exports.applyRowFn = exports.isGridCellContent = exports.toContent = void 0;
4
4
  const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
5
+ const Icon_1 = require("../../Icon");
5
6
  const ExpandableHeader_1 = require("../components/ExpandableHeader");
6
7
  const SortHeader_1 = require("../components/SortHeader");
7
8
  const Css_1 = require("../../../Css");
@@ -26,6 +27,8 @@ function toContent(maybeContent, isHeader, canSortColumn, isClientSideSorting, s
26
27
  // for those tables.
27
28
  throw new Error("GridTables with as=virtual & sortable columns should use functions that return JSX, instead of JSX");
28
29
  }
30
+ const tooltip = isGridCellContent(maybeContent) ? maybeContent.tooltip : undefined;
31
+ const tooltipEl = tooltip ? ((0, jsx_runtime_1.jsx)("span", { css: Css_1.Css.fs0.mlPx(4).$, children: (0, jsx_runtime_1.jsx)(Icon_1.Icon, { icon: "infoCircle", tooltip: tooltip, inc: 2, color: Css_1.Palette.Gray600 }) })) : null;
29
32
  content =
30
33
  isGridCellContent(maybeContent) && !!maybeContent.onClick
31
34
  ? (0, getInteractiveElement_1.getButtonOrLink)(content, maybeContent.onClick, {
@@ -33,27 +36,27 @@ function toContent(maybeContent, isHeader, canSortColumn, isClientSideSorting, s
33
36
  })
34
37
  : content;
35
38
  if (content && typeof content === "string" && isHeader && canSortColumn) {
36
- return ((0, jsx_runtime_1.jsx)(SortHeader_1.SortHeader, { content: content, iconOnLeft: alignment === "right", sortKey: (_b = column.serverSideSortKey) !== null && _b !== void 0 ? _b : column.id }));
39
+ return ((0, jsx_runtime_1.jsx)(SortHeader_1.SortHeader, { content: content, iconOnLeft: alignment === "right", sortKey: (_b = column.serverSideSortKey) !== null && _b !== void 0 ? _b : column.id, tooltipEl: tooltipEl }));
37
40
  }
38
41
  else if (content && typeof content === "string" && isExpandableHeader && isExpandable) {
39
- return (0, jsx_runtime_1.jsx)(ExpandableHeader_1.ExpandableHeader, { title: content, column: column, minStickyLeftOffset: minStickyLeftOffset, as: as });
42
+ return ((0, jsx_runtime_1.jsx)(ExpandableHeader_1.ExpandableHeader, { title: content, column: column, minStickyLeftOffset: minStickyLeftOffset, as: as, tooltipEl: tooltipEl }));
40
43
  }
41
44
  else if (content && typeof content === "string" && isExpandableHeader) {
42
- return (0, jsx_runtime_1.jsx)("span", { css: Css_1.Css.lineClamp2.$, children: content });
45
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", { css: Css_1.Css.lineClamp2.$, children: content }), tooltipEl] }));
43
46
  }
44
47
  else if (!isContentEmpty(content) && isHeader && typeof content === "string") {
45
- return ((0, jsx_runtime_1.jsx)("span", { css: Css_1.Css.lineClamp2.$, title: content, children: content }));
48
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", { css: Css_1.Css.lineClamp2.$, title: content, children: content }), tooltipEl] }));
46
49
  }
47
50
  else if (!isHeader && content && ((_c = style === null || style === void 0 ? void 0 : style.presentationSettings) === null || _c === void 0 ? void 0 : _c.wrap) === false && typeof content === "string") {
48
51
  // In order to truncate the text properly, then we need to wrap it in another element
49
52
  // as our cell element is a flex container, which don't allow for applying truncation styles directly on it.
50
- return ((0, jsx_runtime_1.jsx)("span", { css: Css_1.Css.truncate.mw0.$, title: content, children: content }));
53
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", { css: Css_1.Css.truncate.mw0.$, title: content, children: content }), tooltipEl] }));
51
54
  }
52
55
  else if (style.emptyCell && isContentEmpty(content)) {
53
56
  // If the content is empty and the user specified an `emptyCell` node, return that.
54
57
  return style.emptyCell;
55
58
  }
56
- return content;
59
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [content, tooltipEl] }));
57
60
  }
58
61
  exports.toContent = toContent;
59
62
  function isGridCellContent(content) {
@@ -133,11 +133,10 @@ function ComboBoxBase(props) {
133
133
  maybeInitLoad();
134
134
  firstOpen.current = false;
135
135
  }
136
- setFieldState((prevState) => ({
137
- ...prevState,
138
- // When using the multiselect field, always empty the input upon open.
139
- inputValue: multiselect && isOpen ? "" : prevState.inputValue,
140
- }));
136
+ // When using the multiselect field, always empty the input upon open.
137
+ if (multiselect && isOpen) {
138
+ setFieldState((prevState) => ({ ...prevState, inputValue: "" }));
139
+ }
141
140
  }
142
141
  // Used to calculate the rendered width of the combo box (input + button)
143
142
  const comboBoxRef = (0, react_1.useRef)(null);
@@ -163,6 +162,9 @@ function ComboBoxBase(props) {
163
162
  const state = (0, react_stately_1.useComboBoxState)({
164
163
  ...comboBoxProps,
165
164
  allowsEmptyCollection: true,
165
+ // We don't really allow custom values, as we reset the input value once a user `blur`s the input field.
166
+ // Though, setting `allowsCustomValue: true` prevents React-Aria/Stately from attempting to reset the input field's value when the menu closes.
167
+ allowsCustomValue: true,
166
168
  // useComboBoxState.onSelectionChange will be executed if a keyboard interaction (Enter key) is used to select an item
167
169
  onSelectionChange: (key) => {
168
170
  // ignore undefined/null keys - `null` can happen if input field's value is completely deleted after having a value assigned.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.265.0",
3
+ "version": "2.266.1",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",