@homebound/beam 2.199.1 → 2.199.2

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,10 +1,9 @@
1
- import { GridColumnWithId } from "../types";
2
1
  import { Properties } from "../../../Css";
3
2
  interface SortHeaderProps {
4
3
  content: string;
5
4
  xss?: Properties;
6
5
  iconOnLeft?: boolean;
7
- column: GridColumnWithId<any>;
6
+ sortKey: string;
8
7
  }
9
8
  /**
10
9
  * Wraps column header names with up/down sorting icons.
@@ -20,13 +20,12 @@ 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, column } = props;
23
+ const { content, xss, iconOnLeft = false, sortKey } = props;
24
24
  const { isHovered, hoverProps } = (0, hooks_1.useHover)({});
25
- const ourSortKey = column.serverSideSortKey || column.id;
26
25
  const { tableState } = (0, react_1.useContext)(TableState_1.TableStateContext);
27
26
  const current = (0, hooks_1.useComputed)(() => { var _a; return (_a = tableState.sortState) === null || _a === void 0 ? void 0 : _a.current; }, [tableState]);
28
- const sorted = ourSortKey === (current === null || current === void 0 ? void 0 : current.columnId) ? current === null || current === void 0 ? void 0 : current.direction : undefined;
29
- const toggleSort = (0, react_1.useCallback)(() => tableState.setSortKey(ourSortKey), [ourSortKey, tableState]);
27
+ const sorted = sortKey === (current === null || current === void 0 ? void 0 : current.columnId) ? current === null || current === void 0 ? void 0 : current.direction : undefined;
28
+ const toggleSort = (0, react_1.useCallback)(() => tableState.setSortKey(sortKey), [sortKey, tableState]);
30
29
  const tid = (0, useTestIds_1.useTestIds)(props, "sortHeader");
31
30
  const icon = ((0, jsx_runtime_1.jsx)("span", Object.assign({ css: Css_1.Css.fs0.$ }, { children: (0, jsx_runtime_1.jsx)(Icon_1.Icon, Object.assign({ icon: sorted === "DESC" ? "sortDown" : "sortUp", color: sorted !== undefined ? Css_1.Palette.LightBlue700 : Css_1.Palette.Gray400, xss: {
32
31
  ...Css_1.Css.ml1.if(iconOnLeft).mr1.ml0.$,
@@ -7,7 +7,7 @@ const Css_1 = require("../../../Css");
7
7
  const getInteractiveElement_1 = require("../../../utils/getInteractiveElement");
8
8
  /** If a column def return just string text for a given row, apply some default styling. */
9
9
  function toContent(maybeContent, isHeader, canSortColumn, isClientSideSorting, style, as, alignment, column) {
10
- var _a, _b;
10
+ var _a, _b, _c;
11
11
  let content = isGridCellContent(maybeContent) ? maybeContent.content : maybeContent;
12
12
  if (typeof content === "function") {
13
13
  // Actually create the JSX by calling `content()` here (which should be as late as
@@ -32,9 +32,9 @@ function toContent(maybeContent, isHeader, canSortColumn, isClientSideSorting, s
32
32
  })
33
33
  : content;
34
34
  if (content && typeof content === "string" && isHeader && canSortColumn) {
35
- return (0, jsx_runtime_1.jsx)(SortHeader_1.SortHeader, { content: content, iconOnLeft: alignment === "right", column: column }, void 0);
35
+ 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 }, void 0));
36
36
  }
37
- else if (content && ((_b = style === null || style === void 0 ? void 0 : style.presentationSettings) === null || _b === void 0 ? void 0 : _b.wrap) === false && typeof content === "string") {
37
+ else if (content && ((_c = style === null || style === void 0 ? void 0 : style.presentationSettings) === null || _c === void 0 ? void 0 : _c.wrap) === false && typeof content === "string") {
38
38
  // In order to truncate the text properly, then we need to wrap it in another element
39
39
  // as our cell element is a flex container, which don't allow for applying truncation styles directly on it.
40
40
  return ((0, jsx_runtime_1.jsx)("span", Object.assign({ css: Css_1.Css.truncate.mw0.$, title: content }, { children: content }), void 0));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.199.1",
3
+ "version": "2.199.2",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",