@ai-matrx/records-ui 0.115.103 → 0.115.104

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/index.js CHANGED
@@ -12016,6 +12016,11 @@ import { useCallback as useCallback12, useEffect as useEffect25, useState as use
12016
12016
  import { Button as Button24 } from "@ai-matrx/design-system";
12017
12017
  import { tableShapeChanged as tableShapeChanged4, useRecordsClient as useRecordsClient17 } from "@ai-matrx/records/react";
12018
12018
 
12019
+ // src/leadingBlank.ts
12020
+ function withoutLeadingBlank(text) {
12021
+ return text.replace(/^\s+/, "");
12022
+ }
12023
+
12019
12024
  // src/values.tsx
12020
12025
  init_personChip();
12021
12026
  import { SWATCH_CLASS as SWATCH_CLASS2, formatColumnValue } from "@ai-matrx/design-system/data-table";
@@ -13709,9 +13714,9 @@ function RecordsTable({ items }) {
13709
13714
  const pictureFirst = [...keys].sort((a, b) => rank(a, items) - rank(b, items)).slice(0, TABLE_COLUMNS);
13710
13715
  const shown5 = all ? items : items.slice(0, TABLE_ROWS);
13711
13716
  return /* @__PURE__ */ jsxs38("div", { className: "min-w-0", "data-records-structured": "table", children: [
13712
- /* @__PURE__ */ jsx43("div", { className: "max-w-full overflow-x-auto rounded-md border border-border", children: /* @__PURE__ */ jsxs38("table", { className: "w-full border-collapse text-xs", children: [
13717
+ /* @__PURE__ */ jsx43("div", { className: "max-w-full overflow-x-auto rounded-md border border-border", "data-records-structured-table-frame": "", children: /* @__PURE__ */ jsxs38("table", { className: "w-full border-collapse text-xs", children: [
13713
13718
  /* @__PURE__ */ jsx43("thead", { className: "bg-muted/60 text-left", children: /* @__PURE__ */ jsx43("tr", { children: pictureFirst.map((k) => /* @__PURE__ */ jsx43("th", { scope: "col", className: "whitespace-nowrap px-2 py-1 font-medium text-muted-foreground", children: keyWords(k) }, k)) }) }),
13714
- /* @__PURE__ */ jsx43("tbody", { children: shown5.map((item, i) => /* @__PURE__ */ jsx43("tr", { className: "border-t border-border/60 align-top", children: pictureFirst.map((k) => /* @__PURE__ */ jsx43("td", { className: "min-w-[7rem] max-w-[18rem] px-2 py-1", children: k in item ? /* @__PURE__ */ jsx43(Nested, { value: item[k], keyName: k, dense: true }) : /* @__PURE__ */ jsx43("span", { className: "text-muted-foreground", children: "\u2014" }) }, k)) }, i)) })
13719
+ /* @__PURE__ */ jsx43("tbody", { children: shown5.map((item, i) => /* @__PURE__ */ jsx43("tr", { className: "border-t border-border/60 align-top", children: pictureFirst.map((k) => /* @__PURE__ */ jsx43("td", { className: "min-w-[4rem] max-w-[18rem] break-words px-2 py-1 [overflow-wrap:anywhere]", children: k in item ? /* @__PURE__ */ jsx43(Nested, { value: item[k], keyName: k, dense: true }) : /* @__PURE__ */ jsx43("span", { className: "text-muted-foreground", children: "\u2014" }) }, k)) }, i)) })
13715
13720
  ] }) }),
13716
13721
  items.length > TABLE_ROWS ? /* @__PURE__ */ jsx43(Button23, { type: "button", variant: "ghost", size: "sm", className: "mt-1 h-6 px-2 text-xs", onClick: (e) => {
13717
13722
  stop(e);
@@ -14122,7 +14127,7 @@ function scalarText(field2, value, labels, stillWaitingFor) {
14122
14127
  }
14123
14128
  if (Array.isArray(value)) return value.length === 0 ? "" : structuredSummary(value);
14124
14129
  if (typeof value === "object") return structuredOf(value) ? structuredSummary(value) : "\u2026";
14125
- return String(value);
14130
+ return typeof value === "string" ? withoutLeadingBlank(value) : String(value);
14126
14131
  }
14127
14132
  function ProvenanceBadge({ document: document2, fieldKey }) {
14128
14133
  const envelope = envelopeFor(document2, fieldKey);
@@ -14172,7 +14177,7 @@ function RecordValue({
14172
14177
  }
14173
14178
  if (inCell && ui.grid === "merged" && ui.renderText && typeof value === "string" && value.trim() !== "" && editorKindFor(field2) === "long_text" && !shownAsOf(field2) && !wholeValueOf(document2, field2.key) && !envelopeFor(document2, field2.key)?.absent && // A long-text cell holding a kind is drawn by the kind system below, not as markdown.
14174
14179
  !kindValueOf(value)) {
14175
- return /* @__PURE__ */ jsx44("span", { className: "block h-[1.5em] min-w-0 overflow-hidden whitespace-normal [[data-matrx-cell-lines]:not([data-matrx-cell-lines=one])_&]:h-auto", "data-records-cell-text": "", children: ui.renderText(value, "cell") });
14180
+ return /* @__PURE__ */ jsx44("span", { className: "block h-[1.5em] min-w-0 overflow-hidden whitespace-normal [[data-matrx-cell-lines]:not([data-matrx-cell-lines=one])_&]:h-auto", "data-records-cell-text": "", children: ui.renderText(withoutLeadingBlank(value), "cell") });
14176
14181
  }
14177
14182
  if (isSignatureField(field2) && value !== null && value !== void 0 && value !== "") {
14178
14183
  return /* @__PURE__ */ jsx44(SignatureValue, { value, inCell, recordId, fieldKey: field2.key, document: document2 });
@@ -16992,12 +16997,39 @@ function buttonPressWords(label, pressed) {
16992
16997
  }
16993
16998
  var POLL_EVERY_MS = 1200;
16994
16999
  var POLL_FOR_MS = 12e4;
16995
- function runAnswerWords(label, run) {
17000
+ var RUN_BOOKKEEPING = /* @__PURE__ */ new Set(["run_id", "conversation_id"]);
17001
+ function answerOf(output) {
17002
+ const raw = (output ?? "").trim();
17003
+ if (raw === "") return { words: "" };
17004
+ let parsed;
17005
+ try {
17006
+ parsed = JSON.parse(raw);
17007
+ } catch {
17008
+ return { words: raw };
17009
+ }
17010
+ if (typeof parsed === "string") return { words: parsed.trim() };
17011
+ if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) {
17012
+ const shown5 = Object.fromEntries(Object.entries(parsed).filter(([k]) => !RUN_BOOKKEEPING.has(k)));
17013
+ const keys = Object.keys(shown5);
17014
+ if (keys.length === 1 && typeof shown5.text === "string") return { words: shown5.text.trim() };
17015
+ const value2 = structuredOf(shown5);
17016
+ return value2 ? { words: "", value: value2 } : { words: raw };
17017
+ }
17018
+ const value = structuredOf(parsed);
17019
+ return value ? { words: "", value } : { words: raw };
17020
+ }
17021
+ function runAnswer(label, run) {
16996
17022
  const steps = run.steps ?? [];
16997
17023
  const failedStep = [...steps].reverse().find((s) => s.status === "failed");
16998
- if (run.status === "failed") return [failedStep?.output_text ?? failedStep?.says, run.says].filter((t, i, all) => t && all.indexOf(t) === i).join(" ") || `${label} failed.`;
16999
- const answered = [...steps].reverse().find((s) => s.output_text && s.output_text.trim() !== "");
17000
- return answered?.output_text?.trim() || run.says || `${label} ran.`;
17024
+ if (run.status === "failed") {
17025
+ const failed = answerOf(failedStep?.output_text).words || failedStep?.says;
17026
+ return { words: [failed, run.says].filter((t, i, all) => t && all.indexOf(t) === i).join(" ") || `${label} failed.` };
17027
+ }
17028
+ for (const step2 of [...steps].reverse()) {
17029
+ const answered = answerOf(step2.output_text);
17030
+ if (answered.words !== "" || answered.value) return answered;
17031
+ }
17032
+ return { words: run.says || `${label} ran.` };
17001
17033
  }
17002
17034
  var stop2 = (event) => event.stopPropagation();
17003
17035
  function ButtonValue({ field: field2, recordId, inCell }) {
@@ -17044,7 +17076,8 @@ function ButtonValue({ field: field2, recordId, inCell }) {
17044
17076
  const run = runs.data.runs.find((r) => r.run_id === pressed.run_id);
17045
17077
  if (run && run.status !== "waiting") {
17046
17078
  setBusy(false);
17047
- return setSaid(run.status === "ran" ? { kind: "ran", says: runAnswerWords(b.label, run) } : { kind: "failed", says: runAnswerWords(b.label, run) });
17079
+ const answer = runAnswer(b.label, run);
17080
+ return setSaid(run.status === "ran" ? { kind: "ran", says: answer.words, value: answer.value } : { kind: "failed", says: answer.words });
17048
17081
  }
17049
17082
  if (Date.now() > until) {
17050
17083
  setBusy(false);
@@ -17093,7 +17126,8 @@ function ButtonValue({ field: field2, recordId, inCell }) {
17093
17126
  said2?.kind === "waiting" ? /* @__PURE__ */ jsx53("p", { className: "matrx-shimmer rounded px-1 py-0.5", role: "status", "aria-live": "polite", children: said2.says }) : null,
17094
17127
  said2?.kind === "failed" ? /* @__PURE__ */ jsx53("p", { className: "break-words text-destructive", role: "alert", children: said2.says }) : null,
17095
17128
  said2?.kind === "public" ? /* @__PURE__ */ jsx53("p", { children: "Buttons run for signed-in people." }) : null,
17096
- said2?.kind === "ran" ? /* @__PURE__ */ jsxs48("p", { className: "break-words", children: [
17129
+ said2?.kind === "ran" ? /* @__PURE__ */ jsxs48("div", { className: "break-words", children: [
17130
+ said2.value ? /* @__PURE__ */ jsx53(StructuredValueView, { structured: said2.value, label: b.label }) : null,
17097
17131
  said2.says,
17098
17132
  " ",
17099
17133
  said2.link ? /* @__PURE__ */ jsx53(OutboundLink7, { href: said2.link, className: "text-primary underline", children: said2.link }) : null
@@ -23799,7 +23833,7 @@ function WholeTextDialog({
23799
23833
  /* @__PURE__ */ jsx77(Button44, { size: "sm", variant: reading ? "ghost" : "secondary", role: "tab", "aria-selected": !reading, onClick: () => setReading(false), "data-records-whole-text-mode": "words", children: mayWrite ? "Edit" : "Words" }),
23800
23834
  /* @__PURE__ */ jsx77(Button44, { size: "sm", variant: reading ? "secondary" : "ghost", role: "tab", "aria-selected": reading, onClick: () => setReading(true), "data-records-whole-text-mode": "preview", children: "Preview" })
23801
23835
  ] }) : null,
23802
- ready && reading && renderText ? /* @__PURE__ */ jsx77("div", { className: "max-h-[60vh] min-h-[8rem] overflow-auto rounded-md border px-3 py-2 text-sm", "data-records-whole-text-preview": "", children: draft ? renderText(draft, "cell") : /* @__PURE__ */ jsx77("span", { className: "text-muted-foreground", children: "\u2014" }) }) : ready && textBox ? (
23836
+ ready && reading && renderText ? /* @__PURE__ */ jsx77("div", { className: "max-h-[60vh] min-h-[8rem] overflow-auto rounded-md border px-3 py-2 text-sm", "data-records-whole-text-preview": "", children: draft ? renderText(withoutLeadingBlank(draft), "cell") : /* @__PURE__ */ jsx77("span", { className: "text-muted-foreground", children: "\u2014" }) }) : ready && textBox ? (
23803
23837
  // THE HOST'S TEXT BOX (`textBox`): the same words, with its "…" menu (Clean up, Help with
23804
23838
  // this…, Copy, Save, Share). What its menu puts in the box is unsaved until Save.
23805
23839
  /* @__PURE__ */ jsx77("div", { "data-records-whole-text-box": "", children: textBox({
@@ -57942,7 +57976,7 @@ function TablePage({
57942
57976
  // `min-w-9`: never narrower than the layout toolbar's folded "…" (36 px) — a row too
57943
57977
  // narrow for its pinned controls folds them behind that "…" (design-system
57944
57978
  // `usePinnedFold`), and the "…" itself is never cut (merged-grid leftovers, 2026-09-28).
57945
- "flex min-w-9 flex-1 items-center overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",
57979
+ "flex min-w-9 flex-1 items-center overflow-x-auto whitespace-nowrap [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",
57946
57980
  slotClipped === "end" && "[mask-image:linear-gradient(to_right,black_calc(100%_-_2rem),transparent)]",
57947
57981
  slotClipped === "start" && "[mask-image:linear-gradient(to_left,black_calc(100%_-_2rem),transparent)]",
57948
57982
  slotClipped === "both" && "[mask-image:linear-gradient(to_right,transparent,black_2rem,black_calc(100%_-_2rem),transparent)]",