@agilant/toga-blox 1.0.196 → 1.0.197

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.
@@ -9,6 +9,8 @@ export interface TableCellProps<T extends DataWithUUID> {
9
9
  linkText?: string;
10
10
  cellExpandable?: boolean;
11
11
  maxCharacters?: number;
12
+ maxWidthWhenExpanded?: number;
13
+ cellColor: string;
12
14
  }
13
- declare const TableCell: <T extends DataWithUUID>({ cell, isLastCell, hasInfiniteScroll, expanded, onToggle, linkText, cellExpandable, maxCharacters, }: TableCellProps<T>) => import("react/jsx-runtime").JSX.Element;
15
+ declare const TableCell: <T extends DataWithUUID>({ cell, isLastCell, hasInfiniteScroll, expanded, onToggle, linkText, cellExpandable, maxCharacters, maxWidthWhenExpanded, cellColor, }: TableCellProps<T>) => import("react/jsx-runtime").JSX.Element;
14
16
  export default TableCell;
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  const MAX_CHARS = 30;
3
- const TableCell = ({ cell, isLastCell, hasInfiniteScroll, expanded, onToggle, linkText = "text-purple-500 ml-1 underline", cellExpandable = false, maxCharacters, }) => {
3
+ const TableCell = ({ cell, isLastCell, hasInfiniteScroll, expanded, onToggle, linkText = "text-purple-500 ml-1 underline", cellExpandable = false, maxCharacters, maxWidthWhenExpanded = 50, cellColor = "bg-blue-50", }) => {
4
4
  /* decide if this cell even needs a toggle */
5
5
  const isString = typeof cell.value === "string";
6
6
  const fullText = isString ? cell.value : "";
@@ -18,7 +18,7 @@ const TableCell = ({ cell, isLastCell, hasInfiniteScroll, expanded, onToggle, li
18
18
  : 0;
19
19
  const stickyClass = isStickyColumn ? cell.column?.className || "" : "";
20
20
  const baseTd = "relative overflow-hidden font-light text-sm text-left px-5";
21
- const wrapper = "min-h-[40px] flex select-none" + (hasToggle ? " cursor-pointer" : "");
21
+ const wrapper = `${cellColor} min-h-[40px] flex select-none${hasToggle ? " cursor-pointer" : ""}`;
22
22
  // FIX: extract key before spreading props into <td>
23
23
  const rawCellProps = cell.getCellProps({
24
24
  className: isLastCell ? "" : baseTd,
@@ -33,11 +33,13 @@ const TableCell = ({ cell, isLastCell, hasInfiniteScroll, expanded, onToggle, li
33
33
  const { key: cellKey, ...safeCellProps } = Object.assign({}, rawCellProps);
34
34
  return (_jsx("td", { ...safeCellProps, className: isStickyColumn ? undefined : isLastCell ? "" : baseTd, children: _jsx("div", { className: wrapper, children: hasToggle ? (!expanded ? (
35
35
  /* collapsed view */
36
- _jsx("div", { className: "flex items-center group", children: _jsxs("span", { children: [truncated, "\u2026", _jsx("span", { ...(hasToggle
36
+ _jsx("div", { className: "flex items-start group", children: _jsxs("span", { children: [truncated, "\u2026", _jsx("span", { ...(hasToggle
37
37
  ? { onClick: handleToggle }
38
38
  : {}), className: `hidden group-hover:inline ${linkText}`, children: "Show more" })] }) })) : (
39
39
  /* expanded view */
40
- _jsxs("div", { className: "flex flex-col", children: [_jsx("span", { children: fullText }), _jsx("span", { ...(hasToggle
40
+ _jsxs("div", { className: `flex flex-col `, style: {
41
+ maxWidth: `${maxWidthWhenExpanded}ch`,
42
+ }, children: [_jsx("span", { children: fullText }), _jsx("span", { ...(hasToggle
41
43
  ? { onClick: handleToggle }
42
44
  : {}), className: linkText, children: "Show less" })] }))) : (
43
45
  /* no toggle required */
@@ -37,7 +37,7 @@ const Template = (args) => {
37
37
  getCellProps: () => ({}),
38
38
  column: {},
39
39
  };
40
- return (_jsx("table", { children: _jsx("tbody", { children: _jsx("tr", { children: _jsx(TableCell, { ...args, cell: fakeCell, expanded: expanded, onToggle: () => setExpanded((e) => !e) }) }) }) }));
40
+ return (_jsx("table", { children: _jsx("tbody", { children: _jsx("tr", { children: _jsx(TableCell, { cellColor: "", ...args, cell: fakeCell, expanded: expanded, onToggle: () => setExpanded((e) => !e) }) }) }) }));
41
41
  };
42
42
  /* ---------- stories ---------- */
43
43
  export const Default = Template.bind({});
@@ -55,7 +55,7 @@ const defaultProps = {
55
55
  };
56
56
  describe("TableCell Component", () => {
57
57
  it("trims the text when globalTrimActive is true", () => {
58
- render(_jsx("table", { children: _jsx("tbody", { children: _jsx("tr", { children: _jsx(TableCell, { expanded: false, onToggle: function () {
58
+ render(_jsx("table", { children: _jsx("tbody", { children: _jsx("tr", { children: _jsx(TableCell, { cellColor: "", expanded: false, onToggle: function () {
59
59
  throw new Error("Function not implemented.");
60
60
  }, ...defaultProps }) }) }) }));
61
61
  const trimmedText = `${sampleData.address.substring(0, 30)}...`;
@@ -63,14 +63,14 @@ describe("TableCell Component", () => {
63
63
  });
64
64
  it("does not trim the text when globalTrimActive is false", () => {
65
65
  const props = { ...defaultProps, globalTrimActive: false };
66
- render(_jsx("table", { children: _jsx("tbody", { children: _jsx("tr", { children: _jsx(TableCell, { expanded: false, onToggle: function () {
66
+ render(_jsx("table", { children: _jsx("tbody", { children: _jsx("tr", { children: _jsx(TableCell, { cellColor: "", expanded: false, onToggle: function () {
67
67
  throw new Error("Function not implemented.");
68
68
  }, ...props }) }) }) }));
69
69
  expect(screen.getByText(sampleData.address)).toBeInTheDocument();
70
70
  });
71
71
  it("applies different styles when isLastCell is true", () => {
72
72
  const props = { ...defaultProps, isLastCell: true };
73
- render(_jsx("table", { children: _jsx("tbody", { children: _jsx("tr", { children: _jsx(TableCell, { expanded: false, onToggle: function () {
73
+ render(_jsx("table", { children: _jsx("tbody", { children: _jsx("tr", { children: _jsx(TableCell, { cellColor: "", expanded: false, onToggle: function () {
74
74
  throw new Error("Function not implemented.");
75
75
  }, ...props }) }) }) }));
76
76
  const cell = screen.getByRole("cell");
@@ -85,7 +85,7 @@ describe("TableCell Component", () => {
85
85
  render: (type) => (type === "Cell" ? "42" : null),
86
86
  },
87
87
  };
88
- render(_jsx("table", { children: _jsx("tbody", { children: _jsx("tr", { children: _jsx(TableCell, { expanded: false, onToggle: function () {
88
+ render(_jsx("table", { children: _jsx("tbody", { children: _jsx("tr", { children: _jsx(TableCell, { cellColor: "", expanded: false, onToggle: function () {
89
89
  throw new Error("Function not implemented.");
90
90
  }, ...numericValueProps }) }) }) }));
91
91
  expect(screen.getByText("42")).toBeInTheDocument();
@@ -41,7 +41,7 @@ const TableRow = ({ row, prepareRow, activeIndex, activeRowColor = "bg-pink-100"
41
41
  : {};
42
42
  return (_jsxs(Fragment, { children: [_jsx("tr", { "data-testid": "table-row", className: `border-b border-b-navy-200 ${rowHoverClasses} ${rowClasses} ${rowClassNames}`, onClick: handleRowClick, ...safeRowProps, children: row.cells.map((cell, idx) => {
43
43
  const cellKey = `${rowUuid ?? "no-uuid"}-${cell.column.id}`;
44
- return (_jsx(TableCell, { cell: cell, isLastCell: idx === row.cells.length - 1, hasInfiniteScroll: hasInfiniteScroll, cellExpandable: cellExpandable, rowUuid: rowUuid, expanded: expandedCells[cellKey] ?? false, onToggle: () => toggleCell(cellKey), linkText: linkText, maxCharacters: maxCharacters }, cellKey));
44
+ return (_jsx(TableCell, { cell: cell, isLastCell: idx === row.cells.length - 1, hasInfiniteScroll: hasInfiniteScroll, cellExpandable: cellExpandable, rowUuid: rowUuid, expanded: expandedCells[cellKey] ?? false, onToggle: () => toggleCell(cellKey), linkText: linkText, maxCharacters: maxCharacters, cellColor: "" }, cellKey));
45
45
  }) }, rowUuid), hasDropDown && (_jsx(AnimatePresence, { children: isExpanded && (_jsx("tr", { "data-testid": "expanded-row", children: _jsx("td", { colSpan: row.cells.length, className: "p-0", children: _jsx(motion.div, { initial: { height: 0, opacity: 0 }, animate: { height: "auto", opacity: 1 }, exit: { height: 0, opacity: 0 }, transition: { duration: 0.3 }, className: "overflow-hidden w-full", children: isLoading ? (loadingIndicator ?? (_jsx("span", { children: "Loading..." }))) : error ? (errorIndicator ? (errorIndicator(error)) : (_jsxs("span", { className: "text-red-700", children: ["Error: ", error.message] }))) : (expandedContent ?? (_jsxs("span", { children: ["drop down \u2013 ", rowUuid] }))) }, "expanded-dropdown-content") }) })) }))] }));
46
46
  };
47
47
  export default TableRow;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@agilant/toga-blox",
3
3
  "private": false,
4
- "version": "1.0.196",
4
+ "version": "1.0.197",
5
5
  "description": "",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",