@agilant/toga-blox 1.0.163 → 1.0.164

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,26 +1,29 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  // src/components/TableCell/TableCell.tsx
3
3
  import { useState } from "react";
4
4
  const MAX_CHARS = 30;
5
5
  const TableCell = ({ cell, isLastCell, hasInfiniteScroll, linkText = "text-purple-500 ml-1 underline", }) => {
6
6
  const [expanded, setExpanded] = useState(false);
7
- // Determine if we need a toggle
7
+ /* ---------- compute toggle state ---------- */
8
8
  const isString = typeof cell.value === "string";
9
9
  const fullText = isString ? cell.value : "";
10
10
  const isLong = isString && fullText.length > MAX_CHARS;
11
11
  const hasToggle = hasInfiniteScroll && isLong;
12
12
  const truncated = fullText.slice(0, MAX_CHARS);
13
- // Only stop propagation / toggle when hasToggle is true
13
+ /* ---------- click only when toggling ---------- */
14
14
  const handleToggle = (e) => {
15
15
  e.stopPropagation();
16
- setExpanded((prev) => !prev);
16
+ setExpanded((p) => !p);
17
17
  };
18
- const baseTdCls = "relative overflow-hidden font-light text-sm text-left px-5";
19
- const cellWrapperCls = "min-h-[40px] flex items-center";
20
- return (_jsx("td", { ...cell.getCellProps(), className: isLastCell ? "" : baseTdCls, children: _jsx("div", { className: cellWrapperCls, ...(hasToggle
21
- ? { onClick: handleToggle, style: { cursor: "pointer" } }
22
- : {}), children: hasToggle ? (!expanded ? (_jsxs(_Fragment, { children: [truncated, _jsx("span", { className: "inline group-hover:hidden", children: "\u2026" }), _jsx("span", { className: linkText, children: "Show more" })] })) : (_jsxs(_Fragment, { children: [fullText, _jsx("span", { className: linkText, children: "Show less" })] }))) : (
23
- /* no toggle: render normally, clicks bubble to row */
18
+ /* ---------- classes ---------- */
19
+ const baseTd = "relative overflow-hidden font-light text-sm text-left px-5";
20
+ const wrapper = "min-h-[40px] flex select-none" + (hasToggle ? " cursor-pointer" : "");
21
+ return (_jsx("td", { ...cell.getCellProps(), className: isLastCell ? "" : baseTd, children: _jsx("div", { ...(hasToggle ? { onClick: handleToggle } : {}), className: wrapper, children: hasToggle ? (!expanded ? (
22
+ /* collapsed: inline with ellipsis + hover‑only link */
23
+ _jsxs("div", { className: "flex items-center group", children: [_jsx("span", { children: truncated }), _jsx("span", { className: "inline group-hover:hidden", children: "\u2026" }), _jsx("span", { className: `hidden group-hover:inline ${linkText}`, children: "Show more" })] })) : (
24
+ /* expanded: vertical stack so "Show less" is below */
25
+ _jsxs("div", { className: "flex flex-col", children: [_jsx("span", { children: fullText }), _jsx("span", { className: linkText, children: "Show less" })] }))) : (
26
+ /* no toggle → let row handle all clicks */
24
27
  cell.render("Cell")) }) }));
25
28
  };
26
29
  export default TableCell;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@agilant/toga-blox",
3
3
  "private": false,
4
- "version": "1.0.163",
4
+ "version": "1.0.164",
5
5
  "description": "",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",