trotl-table 1.0.70 → 1.0.71

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.
package/dist/Table.esm.js CHANGED
@@ -9943,6 +9943,19 @@ function TableInner({
9943
9943
  }
9944
9944
  return a === b;
9945
9945
  }, []);
9946
+ const formatArrayValue = useCallback((value, col) => {
9947
+ if (!Array.isArray(value)) return value;
9948
+ const objectKey = col?.objectKey;
9949
+ const parts = value.map(item => {
9950
+ if (item == null) return "";
9951
+ if (typeof item !== "object") return String(item);
9952
+ if (objectKey && item?.[objectKey] !== undefined) return String(item[objectKey]);
9953
+ if (item.label !== undefined) return String(item.label);
9954
+ if (item.value !== undefined) return String(item.value);
9955
+ return JSON.stringify(item);
9956
+ }).filter(item => item !== "");
9957
+ return parts.join(", ");
9958
+ }, []);
9946
9959
 
9947
9960
  // console.log(extraSearchTerm)
9948
9961
 
@@ -10029,13 +10042,16 @@ function TableInner({
10029
10042
  const query = searchTerm.toLowerCase();
10030
10043
  return dateFiltered.filter(row => columns.some(col => {
10031
10044
  const val = getAccessorValue(row, col.accessor);
10032
- if (val == null) return false;
10033
- return String(val).toLowerCase().includes(query);
10045
+ const normalized = Array.isArray(val) ? formatArrayValue(val, col) : val;
10046
+ if (normalized == null) return false;
10047
+ return String(normalized).toLowerCase().includes(query);
10034
10048
  }));
10035
- }, [searchTerm, columns, urlSearchString, getAccessorValue]);
10049
+ }, [searchTerm, columns, urlSearchString, getAccessorValue, formatArrayValue]);
10036
10050
 
10037
10051
  // Natural-ish comparator: handles nulls, numbers, strings, ISO dates
10038
10052
  const compare = (x, y, dir = "asc") => {
10053
+ if (Array.isArray(x)) x = formatArrayValue(x);
10054
+ if (Array.isArray(y)) y = formatArrayValue(y);
10039
10055
  const nullCmp = () => {
10040
10056
  if (x == null && y == null) return 0;
10041
10057
  if (x == null) return 1; // nulls last
@@ -10470,6 +10486,15 @@ function TableInner({
10470
10486
  title: formatted
10471
10487
  }, formatted);
10472
10488
  }
10489
+ if (col && col.type === 'array') {
10490
+ const arr = Array.isArray(v) ? v : [];
10491
+ const list = formatArrayValue(arr, col);
10492
+ const count = arr.length;
10493
+ const display = count > 0 ? `${count}: ${list}` : "...";
10494
+ return /*#__PURE__*/React__default.createElement("span", {
10495
+ title: list || translate("noData")
10496
+ }, display);
10497
+ }
10473
10498
 
10474
10499
  // If column has dateFormat, format value as date/time
10475
10500
  if (col && col.dateFormat && v) {
@@ -10515,7 +10540,7 @@ function TableInner({
10515
10540
  }
10516
10541
  // existing highlight logic for other fields
10517
10542
  return highlight(String(v));
10518
- }, [highlight, isGrouped, triggerCellCallback, translate]);
10543
+ }, [highlight, isGrouped, triggerCellCallback, translate, formatArrayValue]);
10519
10544
  const showView = buttons.includes("view");
10520
10545
  const showEdit = buttons.includes("edit");
10521
10546
  // show delete only when view is also shown (per request)