@agilant/toga-blox 1.0.205 → 1.0.206

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,3 +1,3 @@
1
1
  import { TableCellProps } from "./types";
2
- declare const TableCell: ({ cell, isLastCell, expanded, onToggle, maxCharacters, cellMaxWidthWhenExpanded, cellColor, additionalCellClassNames, toggleComponent: ToggleComponent, cellExpandable, linkTextClassNames, cellTextClassNames, onOverflow, }: TableCellProps) => import("react/jsx-runtime").JSX.Element;
2
+ declare const TableCell: ({ cell, isLastCell, expanded, onToggle, maxCharacters, cellMaxWidthWhenExpanded, cellColor, additionalCellClassNames, toggleComponent: ToggleComponent, cellExpandable, linkTextClassNames, cellTextClassNames, onOverflow, cellKey, }: TableCellProps) => import("react/jsx-runtime").JSX.Element;
3
3
  export default TableCell;
@@ -8,7 +8,7 @@ const DefaultCollapsedToggle = ({ onToggle, truncated, className = "", linkTextC
8
8
  e.stopPropagation();
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
- 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 = "", onOverflow = () => { }, }) => {
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 = "", onOverflow = () => { }, cellKey, }) => {
12
12
  // --- truncation logic ---
13
13
  const isString = typeof cell.value === "string";
14
14
  const fullText = isString ? cell.value : "";
@@ -30,10 +30,9 @@ const TableCell = ({ cell, isLastCell, expanded, onToggle, maxCharacters = DEFAU
30
30
  }
31
31
  : {},
32
32
  });
33
- const { key: cellKey, ...safeCellProps } = rawCellProps;
33
+ const { key: domKey, ...safeCellProps } = rawCellProps;
34
34
  useEffect(() => {
35
- if (onOverflow)
36
- onOverflow(isLong);
35
+ onOverflow(isLong);
37
36
  }, [isLong, onOverflow]);
38
37
  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
38
  maxWidth: `${cellMaxWidthWhenExpanded}ch`,
@@ -36,4 +36,5 @@ export interface TableCellProps {
36
36
  linkTextClassNames?: string;
37
37
  cellTextClassNames: string;
38
38
  onOverflow?: (overflowing: boolean) => void;
39
+ cellKey: string;
39
40
  }
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  // src/components/TableRow/TableRow.tsx
3
- import { Fragment, useState, useCallback } from "react";
3
+ import { Fragment, useState } from "react";
4
4
  import { motion, AnimatePresence } from "framer-motion";
5
5
  import TableCell from "../TableCell";
6
6
  const TableRow = ({ row, prepareRow, activeIndex, activeRowColor = "bg-pink-100", rowHoverClasses = "hover:bg-navy-100 hover:cursor-pointer", rowClassNames = "", hasInfiniteScroll, rowUuid, onRowClick, expandedCells, toggleCell, hasDropDown = false, onFetchRowData, loadingIndicator, errorIndicator, expandedContent, expandedRowUuid = null, cellExpandable = false, onToggleRow, maxCharacters = 30, cellColor = "bg-blue-50", cellMaxWidthWhenExpanded = 50, additionalCellClassNames = "", toggleComponent = undefined, linkTextClassNames = "", cellTextClassNames = "", onCellOverflow, }) => {
@@ -39,12 +39,12 @@ const TableRow = ({ row, prepareRow, activeIndex, activeRowColor = "bg-pink-100"
39
39
  const { key: _ignoredKey, ...safeRowProps } = row.getRowProps
40
40
  ? row.getRowProps()
41
41
  : {};
42
- const getOverflowHandler = useCallback((cellKey) => (isOverflowing) => {
43
- onCellOverflow?.(cellKey, isOverflowing);
44
- }, [onCellOverflow]);
45
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) => {
46
43
  const cellKey = `${rowUuid ?? "no-uuid"}-${cell.column.id}`;
47
- return (_jsx(TableCell, { cell: cell, isLastCell: idx === row.cells.length - 1, hasInfiniteScroll: hasInfiniteScroll, cellExpandable: cellExpandable, expanded: expandedCells[cellKey] ?? false, onToggle: () => toggleCell(cellKey), linkTextClassNames: linkTextClassNames, maxCharacters: maxCharacters, cellColor: cellColor, cellMaxWidthWhenExpanded: cellMaxWidthWhenExpanded, additionalCellClassNames: additionalCellClassNames, toggleComponent: toggleComponent, cellTextClassNames: cellTextClassNames, onOverflow: getOverflowHandler(cellKey) }, cellKey));
44
+ const handleOverflow = (isOverflowing) => {
45
+ onCellOverflow?.(cellKey, isOverflowing);
46
+ };
47
+ return (_jsx(TableCell, { cell: cell, isLastCell: idx === row.cells.length - 1, hasInfiniteScroll: hasInfiniteScroll, cellExpandable: cellExpandable, expanded: expandedCells[cellKey] ?? false, onToggle: () => toggleCell(cellKey), linkTextClassNames: linkTextClassNames, maxCharacters: maxCharacters, cellColor: cellColor, cellMaxWidthWhenExpanded: cellMaxWidthWhenExpanded, additionalCellClassNames: additionalCellClassNames, toggleComponent: toggleComponent, cellTextClassNames: cellTextClassNames, onOverflow: handleOverflow, cellKey: cellKey }, cellKey));
48
48
  }) }, 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") }) })) }))] }));
49
49
  };
50
50
  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.205",
4
+ "version": "1.0.206",
5
5
  "description": "",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",