@agilant/toga-blox 1.0.207 → 1.0.208

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,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  // src/components/TableCell/TableCell.tsx
3
- import { useEffect } from "react";
3
+ import { useEffect, useRef } from "react";
4
4
  const DEFAULT_MAX_CHARS = 30;
5
5
  // Default only implements the **collapsed** “Show more” UI.
6
6
  // We’ll never use its expanded branch, since expanded is handled below.
@@ -9,6 +9,7 @@ const DefaultCollapsedToggle = ({ onToggle, truncated, className = "", linkTextC
9
9
  onToggle();
10
10
  }, children: _jsxs("span", { children: [truncated, "\u2026", _jsx("span", { className: `hidden group-hover:inline text-purple-500 ml-1 underline ${linkTextClassNames}`, children: "Show more" })] }) }));
11
11
  const TableCell = ({ cell, isLastCell, expanded, onToggle, maxCharacters = DEFAULT_MAX_CHARS, cellMaxWidthWhenExpanded = 50, cellColor = "bg-blue-500", additionalCellClassNames = "", toggleComponent: ToggleComponent = DefaultCollapsedToggle, cellExpandable = false, linkTextClassNames = "text-purple-500 ml-1 underline", cellTextClassNames = "", onCellOverflow = () => { }, }) => {
12
+ const prev = useRef();
12
13
  // --- truncation logic ---
13
14
  const isString = typeof cell.value === "string";
14
15
  const fullText = isString ? cell.value : "";
@@ -33,7 +34,10 @@ const TableCell = ({ cell, isLastCell, expanded, onToggle, maxCharacters = DEFAU
33
34
  const { key: cellKey, ...safeCellProps } = rawCellProps;
34
35
  console.warn(fullText.length, "LENGTH");
35
36
  useEffect(() => {
36
- onCellOverflow?.(needsToggle);
37
+ if (prev.current !== needsToggle) {
38
+ onCellOverflow(needsToggle);
39
+ prev.current = needsToggle;
40
+ }
37
41
  }, [needsToggle, onCellOverflow]);
38
42
  return (_jsx("td", { ...safeCellProps, className: isStickyColumn ? undefined : isLastCell ? "" : baseTd, children: _jsx("div", { className: wrapper, style: { maxWidth: `${cellMaxWidthWhenExpanded}ch` }, children: needsToggle ? (!expanded ? (_jsx(ToggleComponent, { expanded: expanded, onToggle: onToggle, truncated: truncated, fullText: fullText, className: additionalCellClassNames, linkTextClassNames: linkTextClassNames })) : (_jsxs("div", { className: "flex flex-col", style: {
39
43
  maxWidth: `${cellMaxWidthWhenExpanded}ch`,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@agilant/toga-blox",
3
3
  "private": false,
4
- "version": "1.0.207",
4
+ "version": "1.0.208",
5
5
  "description": "",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",