@ai-matrx/design-system 0.20.2 → 0.20.5

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.
@@ -6850,6 +6850,17 @@ function tokenFromColumnName(name) {
6850
6850
  return name.endsWith("_id") ? name.slice(0, -3) : null;
6851
6851
  }
6852
6852
 
6853
+ // src/data-table/display-value.ts
6854
+ function formatTableDisplayValue(value) {
6855
+ if (typeof value === "number") return value.toLocaleString(void 0, { maximumFractionDigits: 12 });
6856
+ if (value instanceof Date) return value.toLocaleString();
6857
+ if (typeof value === "string" && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/.test(value) && !Number.isNaN(Date.parse(value))) {
6858
+ return new Date(value).toLocaleString();
6859
+ }
6860
+ if (typeof value === "boolean") return value ? "Yes" : "No";
6861
+ return stringifyCellValue(value) || "\u2014";
6862
+ }
6863
+
6853
6864
  // src/data-table/DataRowInspector.tsx
6854
6865
  var import_jsx_runtime33 = require("react/jsx-runtime");
6855
6866
  var noFieldToken = () => null;
@@ -6922,7 +6933,7 @@ function DataRowInspector({
6922
6933
  key
6923
6934
  );
6924
6935
  }
6925
- const formatted = formatValue(value);
6936
+ const formatted = value !== null && typeof value === "object" && !(value instanceof Date) ? formatValue(value) : formatTableDisplayValue(value);
6926
6937
  const multiline = formatted.includes("\n") || formatted.length > 80;
6927
6938
  return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
6928
6939
  "div",
@@ -7051,6 +7062,22 @@ function TabButton({
7051
7062
  );
7052
7063
  }
7053
7064
 
7065
+ // src/data-table/row-title.ts
7066
+ function defaultRowTitle(row, columns) {
7067
+ const values = columns.map((column) => ({
7068
+ id: columnId(column),
7069
+ value: getCellValue(row, column)
7070
+ })).filter(
7071
+ (entry) => typeof entry.value === "string" && entry.value.trim().length > 0
7072
+ );
7073
+ const named = values.find(
7074
+ ({ id, value: value2 }) => inferTableSearchRole(id) === "name" && !isUuidValue(value2)
7075
+ );
7076
+ const identity = values.find(({ id }) => id === "id" || id === "uuid") ?? values.find(({ id }) => inferTableSearchRole(id) === "id");
7077
+ const value = (named ?? identity ?? values[0])?.value.trim();
7078
+ return value ? isUuidValue(value) ? value.slice(0, 8) : value : "Details";
7079
+ }
7080
+
7054
7081
  // src/data-table/DirtySavePill.tsx
7055
7082
  var import_jsx_runtime35 = require("react/jsx-runtime");
7056
7083
  function DirtySavePill({
@@ -8544,25 +8571,6 @@ function MatrxDataTableCore({
8544
8571
  ...appendScrollPolicy?.mode === "scroll" && appendScrollPolicy.intentTimeoutMs !== void 0 ? { intentTimeoutMs: appendScrollPolicy.intentTimeoutMs } : {}
8545
8572
  });
8546
8573
  const rootRef = (0, import_react17.useRef)(null);
8547
- const setDiagnosticBoundaryRef = (0, import_react17.useCallback)((node) => {
8548
- rootRef.current = node;
8549
- if (!node) return;
8550
- node.style.setProperty("outline", "2px solid #2563eb", "important");
8551
- node.style.setProperty("outline-offset", "-2px", "important");
8552
- node.style.setProperty("isolation", "isolate", "important");
8553
- const position = window.getComputedStyle(node).position;
8554
- if (position === "" || position === "static") {
8555
- node.style.setProperty("position", "relative", "important");
8556
- }
8557
- const boundary = node.querySelector(":scope > [data-matrx-table-boundary]");
8558
- if (!boundary) return;
8559
- boundary.style.setProperty("position", "absolute", "important");
8560
- boundary.style.setProperty("inset", "0", "important");
8561
- boundary.style.setProperty("pointer-events", "none", "important");
8562
- boundary.style.setProperty("z-index", "2147483647", "important");
8563
- boundary.style.setProperty("box-sizing", "border-box", "important");
8564
- boundary.style.setProperty("border", "2px solid #2563eb", "important");
8565
- }, []);
8566
8574
  useClippedContentGuard(rootRef, {
8567
8575
  label: typeof copy === "object" && copy.listLabel ? `Table: ${copy.listLabel}` : "MatrxDataTable"
8568
8576
  });
@@ -9603,7 +9611,7 @@ function MatrxDataTableCore({
9603
9611
  /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
9604
9612
  "div",
9605
9613
  {
9606
- ref: setDiagnosticBoundaryRef,
9614
+ ref: rootRef,
9607
9615
  "data-matrx-table": true,
9608
9616
  "data-matrx-table-density": resolvedDensity,
9609
9617
  "data-url-state-table": urlState?.id,
@@ -9612,7 +9620,6 @@ function MatrxDataTableCore({
9612
9620
  className
9613
9621
  ),
9614
9622
  children: [
9615
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { "aria-hidden": "true", "data-matrx-table-boundary": true }),
9616
9623
  notice,
9617
9624
  savedViewError ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { role: "alert", className: "shrink-0 text-xs text-destructive", children: savedViewError }) : null,
9618
9625
  toolbarActionError ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { role: "alert", className: "shrink-0 text-xs text-destructive", children: toolbarActionError }) : null,
@@ -10691,7 +10698,7 @@ function MatrxDataTableCore({
10691
10698
  {
10692
10699
  title: resolveStringTitle(
10693
10700
  detail?.title?.(selectedRow),
10694
- defaultRowTitle(selectedRow, visibleColumns)
10701
+ defaultRowTitle(selectedRow, columns)
10695
10702
  ),
10696
10703
  titleNode: detail?.title?.(selectedRow),
10697
10704
  description: detail?.description?.(selectedRow),
@@ -10758,7 +10765,7 @@ function MatrxDataTableCore({
10758
10765
  {
10759
10766
  isOpen: true,
10760
10767
  onClose: closeWindow,
10761
- title: windowConfig?.title?.(windowRow) ?? defaultRowTitle(windowRow, visibleColumns),
10768
+ title: windowConfig?.title?.(windowRow) ?? defaultRowTitle(windowRow, columns),
10762
10769
  row: windowRow,
10763
10770
  width: windowConfig?.width,
10764
10771
  height: windowConfig?.height,
@@ -11090,7 +11097,8 @@ function normalizeColumnWidthsForColumns(widths, columns) {
11090
11097
  }
11091
11098
  function columnWidthVar(width, resizedWidth, id, resizable) {
11092
11099
  if (width === void 0 && resizedWidth === void 0 && !resizable) return void 0;
11093
- const fallback = resizedWidth === void 0 ? width === void 0 ? "auto" : typeof width === "number" ? `${width}px` : width : `${resizedWidth}px`;
11100
+ const inferredWidth = resizable && inferTableSearchRole(id) === "name" ? "12rem" : "auto";
11101
+ const fallback = resizedWidth === void 0 ? width === void 0 ? inferredWidth : typeof width === "number" ? `${width}px` : width : `${resizedWidth}px`;
11094
11102
  return {
11095
11103
  "--matrx-col-w": resizable ? `var(${columnResizeCssVar(id)}, ${fallback})` : fallback
11096
11104
  };
@@ -11140,19 +11148,12 @@ function renderCell(row, col, index) {
11140
11148
  if (typeof raw === "boolean") {
11141
11149
  return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: raw ? "rounded bg-emerald-500/10 px-1.5 py-0.5 text-xs text-emerald-600" : "rounded bg-slate-500/10 px-1.5 py-0.5 text-xs text-muted-foreground", children: raw ? "Yes" : "No" });
11142
11150
  }
11143
- const formatted = typeof raw === "number" ? raw.toLocaleString(void 0, { maximumFractionDigits: 12 }) : raw instanceof Date ? raw.toLocaleString() : typeof raw === "string" && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/.test(raw) && !Number.isNaN(Date.parse(raw)) ? new Date(raw).toLocaleString() : stringifyCellValue(raw) || "\u2014";
11151
+ const formatted = formatTableDisplayValue(raw);
11144
11152
  return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(Tooltip, { children: [
11145
11153
  /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: "block text-sm text-foreground", style: { display: "-webkit-box", WebkitLineClamp: 2, WebkitBoxOrient: "vertical", overflow: "hidden", overflowWrap: "anywhere" }, children: formatted }) }),
11146
11154
  /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(TooltipContent, { className: "max-w-md whitespace-pre-wrap break-words max-h-80 overflow-auto", children: typeof raw === "object" && raw !== null ? JSON.stringify(raw, null, 2) : formatted })
11147
11155
  ] });
11148
11156
  }
11149
- function defaultRowTitle(row, columns) {
11150
- for (const col of columns) {
11151
- const v = getCellValue(row, col);
11152
- if (typeof v === "string" && v.trim()) return v;
11153
- }
11154
- return "Details";
11155
- }
11156
11157
  function resolveStringTitle(title, fallback) {
11157
11158
  if (typeof title === "string" && title.trim()) return title;
11158
11159
  if (typeof title === "number") return String(title);