@ai-matrx/design-system 0.20.1 → 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.
@@ -2876,9 +2876,14 @@ function PaletteGlyph({ format, ai = false, file = false, kind }) {
2876
2876
  /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("path", { d: "M6 3h8l4 4v14H6z" }),
2877
2877
  /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("path", { d: "M14 3v5h5M9 13h6M9 17h6" })
2878
2878
  ] });
2879
- const path2 = format === "json" ? /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
2879
+ const path2 = format === "json" || format === "table-data" ? /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
2880
2880
  /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("path", { d: "M9 4C7 4 7 7 5 7v3c2 0 2 1 2 2s0 2-2 2v3c2 0 2 3 4 3" }),
2881
2881
  /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("path", { d: "M15 4c2 0 2 3 4 3v3c-2 0-2 1-2 2s0 2 2 2v3c-2 0-2 3-4 3" })
2882
+ ] }) : format === "table-schema" ? /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
2883
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("rect", { x: "8", y: "3", width: "8", height: "5", rx: "1" }),
2884
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("rect", { x: "2", y: "16", width: "8", height: "5", rx: "1" }),
2885
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("rect", { x: "14", y: "16", width: "8", height: "5", rx: "1" }),
2886
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("path", { d: "M12 8v4M6 16v-4h12v4" })
2882
2887
  ] }) : format === "compact-json" ? /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
2883
2888
  /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("path", { d: "m14 10 7-7" }),
2884
2889
  /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("path", { d: "M20 10h-6V4" }),
@@ -3337,7 +3342,7 @@ function ContentTransferMenuSession({ references = [], referenceActions = [], so
3337
3342
  closePalette();
3338
3343
  onClick();
3339
3344
  }, children: [
3340
- Icon3 ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Icon3, { className: "matrx-alchemy-menu-icon" }) : /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(PaletteGlyph, { ...!options.custom ? { format: id } : {}, ...options.ai ? { ai: true } : {}, ...options.file ? { file: true } : {} }),
3345
+ Icon3 ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Icon3, { className: "matrx-alchemy-menu-icon" }) : /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(PaletteGlyph, { format: id, ai: Boolean(options.ai), file: options.file || Boolean(options.custom && id !== "table-data" && id !== "table-schema") }),
3341
3346
  /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("span", { children: [
3342
3347
  label2,
3343
3348
  presentation?.hint ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("small", { className: "matrx-alchemy-menu-hint", children: presentation.hint }) : null
@@ -6845,6 +6850,17 @@ function tokenFromColumnName(name) {
6845
6850
  return name.endsWith("_id") ? name.slice(0, -3) : null;
6846
6851
  }
6847
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
+
6848
6864
  // src/data-table/DataRowInspector.tsx
6849
6865
  var import_jsx_runtime33 = require("react/jsx-runtime");
6850
6866
  var noFieldToken = () => null;
@@ -6917,7 +6933,7 @@ function DataRowInspector({
6917
6933
  key
6918
6934
  );
6919
6935
  }
6920
- const formatted = formatValue(value);
6936
+ const formatted = value !== null && typeof value === "object" && !(value instanceof Date) ? formatValue(value) : formatTableDisplayValue(value);
6921
6937
  const multiline = formatted.includes("\n") || formatted.length > 80;
6922
6938
  return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
6923
6939
  "div",
@@ -7046,6 +7062,22 @@ function TabButton({
7046
7062
  );
7047
7063
  }
7048
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
+
7049
7081
  // src/data-table/DirtySavePill.tsx
7050
7082
  var import_jsx_runtime35 = require("react/jsx-runtime");
7051
7083
  function DirtySavePill({
@@ -8539,25 +8571,6 @@ function MatrxDataTableCore({
8539
8571
  ...appendScrollPolicy?.mode === "scroll" && appendScrollPolicy.intentTimeoutMs !== void 0 ? { intentTimeoutMs: appendScrollPolicy.intentTimeoutMs } : {}
8540
8572
  });
8541
8573
  const rootRef = (0, import_react17.useRef)(null);
8542
- const setDiagnosticBoundaryRef = (0, import_react17.useCallback)((node) => {
8543
- rootRef.current = node;
8544
- if (!node) return;
8545
- node.style.setProperty("outline", "2px solid #2563eb", "important");
8546
- node.style.setProperty("outline-offset", "-2px", "important");
8547
- node.style.setProperty("isolation", "isolate", "important");
8548
- const position = window.getComputedStyle(node).position;
8549
- if (position === "" || position === "static") {
8550
- node.style.setProperty("position", "relative", "important");
8551
- }
8552
- const boundary = node.querySelector(":scope > [data-matrx-table-boundary]");
8553
- if (!boundary) return;
8554
- boundary.style.setProperty("position", "absolute", "important");
8555
- boundary.style.setProperty("inset", "0", "important");
8556
- boundary.style.setProperty("pointer-events", "none", "important");
8557
- boundary.style.setProperty("z-index", "2147483647", "important");
8558
- boundary.style.setProperty("box-sizing", "border-box", "important");
8559
- boundary.style.setProperty("border", "2px solid #2563eb", "important");
8560
- }, []);
8561
8574
  useClippedContentGuard(rootRef, {
8562
8575
  label: typeof copy === "object" && copy.listLabel ? `Table: ${copy.listLabel}` : "MatrxDataTable"
8563
8576
  });
@@ -9598,7 +9611,7 @@ function MatrxDataTableCore({
9598
9611
  /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
9599
9612
  "div",
9600
9613
  {
9601
- ref: setDiagnosticBoundaryRef,
9614
+ ref: rootRef,
9602
9615
  "data-matrx-table": true,
9603
9616
  "data-matrx-table-density": resolvedDensity,
9604
9617
  "data-url-state-table": urlState?.id,
@@ -9607,7 +9620,6 @@ function MatrxDataTableCore({
9607
9620
  className
9608
9621
  ),
9609
9622
  children: [
9610
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { "aria-hidden": "true", "data-matrx-table-boundary": true }),
9611
9623
  notice,
9612
9624
  savedViewError ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { role: "alert", className: "shrink-0 text-xs text-destructive", children: savedViewError }) : null,
9613
9625
  toolbarActionError ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { role: "alert", className: "shrink-0 text-xs text-destructive", children: toolbarActionError }) : null,
@@ -10686,7 +10698,7 @@ function MatrxDataTableCore({
10686
10698
  {
10687
10699
  title: resolveStringTitle(
10688
10700
  detail?.title?.(selectedRow),
10689
- defaultRowTitle(selectedRow, visibleColumns)
10701
+ defaultRowTitle(selectedRow, columns)
10690
10702
  ),
10691
10703
  titleNode: detail?.title?.(selectedRow),
10692
10704
  description: detail?.description?.(selectedRow),
@@ -10753,7 +10765,7 @@ function MatrxDataTableCore({
10753
10765
  {
10754
10766
  isOpen: true,
10755
10767
  onClose: closeWindow,
10756
- title: windowConfig?.title?.(windowRow) ?? defaultRowTitle(windowRow, visibleColumns),
10768
+ title: windowConfig?.title?.(windowRow) ?? defaultRowTitle(windowRow, columns),
10757
10769
  row: windowRow,
10758
10770
  width: windowConfig?.width,
10759
10771
  height: windowConfig?.height,
@@ -11085,7 +11097,8 @@ function normalizeColumnWidthsForColumns(widths, columns) {
11085
11097
  }
11086
11098
  function columnWidthVar(width, resizedWidth, id, resizable) {
11087
11099
  if (width === void 0 && resizedWidth === void 0 && !resizable) return void 0;
11088
- 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`;
11089
11102
  return {
11090
11103
  "--matrx-col-w": resizable ? `var(${columnResizeCssVar(id)}, ${fallback})` : fallback
11091
11104
  };
@@ -11135,19 +11148,12 @@ function renderCell(row, col, index) {
11135
11148
  if (typeof raw === "boolean") {
11136
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" });
11137
11150
  }
11138
- 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);
11139
11152
  return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(Tooltip, { children: [
11140
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 }) }),
11141
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 })
11142
11155
  ] });
11143
11156
  }
11144
- function defaultRowTitle(row, columns) {
11145
- for (const col of columns) {
11146
- const v = getCellValue(row, col);
11147
- if (typeof v === "string" && v.trim()) return v;
11148
- }
11149
- return "Details";
11150
- }
11151
11157
  function resolveStringTitle(title, fallback) {
11152
11158
  if (typeof title === "string" && title.trim()) return title;
11153
11159
  if (typeof title === "number") return String(title);