@ai-matrx/records-ui 0.116.30 → 0.116.31

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.
@@ -4784,7 +4784,7 @@ import { AlchemyMenu } from "@ai-matrx/alchemy/react";
4784
4784
  import { OutboundLink as OutboundLink5 } from "@ai-matrx/kit/outbound-react";
4785
4785
  import { humanizeIdentifier } from "@ai-matrx/kit/text-case";
4786
4786
  import { jsx as jsx26, jsxs as jsxs22 } from "react/jsx-runtime";
4787
- var SaveToTable = lazy(() => import("./SaveToTable-P3MPRSCW.js").then((m) => ({ default: m.SaveToTable })));
4787
+ var SaveToTable = lazy(() => import("./SaveToTable-4AS5YBRT.js").then((m) => ({ default: m.SaveToTable })));
4788
4788
  var LONGEST_READ = 5e5;
4789
4789
  var FENCE = /^```(?:json)?[ \t]*\r?\n([\s\S]*?)\r?\n?```$/;
4790
4790
  function isPlainObject(v) {
@@ -12322,4 +12322,4 @@ export {
12322
12322
  RecordNameText,
12323
12323
  HeldChangeDecision
12324
12324
  };
12325
- //# sourceMappingURL=chunk-2SI7LSP3.js.map
12325
+ //# sourceMappingURL=chunk-BQS26T6D.js.map
package/dist/index.cjs CHANGED
@@ -7241,10 +7241,22 @@ function TablesHome({ onOpenTable, organizationName, makingOnly = false, askedBy
7241
7241
  ) }, board.dashboard_id)) })
7242
7242
  ] }) : null,
7243
7243
  !makingOnly && tables.data && !sectionsKnown ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("p", { className: "text-xs text-muted-foreground", children: SECTIONS_UNKNOWN }) : null,
7244
- !makingOnly && tables.data && keptCount > 0 ? /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { "data-tables-show-everything": showEverything ? "on" : "off", className: "flex flex-wrap items-center gap-2 text-xs text-muted-foreground", children: [
7245
- /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { children: showEverything ? `Showing everything, including the ${keptCount} ${keptCount === 1 ? "table" : "tables"} the app keeps for itself.` : `${keptCount} ${keptCount === 1 ? "table" : "tables"} the app keeps for itself ${keptCount === 1 ? "is" : "are"} not listed here.` }),
7246
- /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_design_system41.Button, { size: "sm", variant: "ghost", className: "h-6 px-2 text-xs", onClick: () => setShowEverything((on) => !on), children: showEverything ? "Hide what the app keeps" : "Show everything" })
7247
- ] }) : null,
7244
+ !makingOnly && tables.data && keptCount > 0 ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { "data-tables-show-everything": showEverything ? "on" : "off", className: "flex items-center text-xs", children: /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
7245
+ import_design_system41.Button,
7246
+ {
7247
+ size: "sm",
7248
+ variant: "ghost",
7249
+ className: "h-6 px-2 text-xs",
7250
+ "aria-pressed": showEverything,
7251
+ onClick: () => setShowEverything((on) => !on),
7252
+ children: [
7253
+ showEverything ? "\u2713 " : "",
7254
+ "Include system tables (",
7255
+ keptCount,
7256
+ ")"
7257
+ ]
7258
+ }
7259
+ ) }) : null,
7248
7260
  !makingOnly && tables.data ? TABLE_LANES.filter((lane) => lane !== "app" || showEverything).map((lane) => {
7249
7261
  const rows = listed.filter(
7250
7262
  (t) => lane === "mine" ? laneFor(t) === "mine" || isMine(t) : laneFor(t) === lane
@@ -29707,10 +29719,7 @@ function EnrichPanel({ tableId, fieldId, className }) {
29707
29719
  /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("span", { className: "truncate text-muted-foreground", children: preview?.find((p) => p.record_id === w.record_id)?.title ?? w.record_id.slice(0, 8) }),
29708
29720
  /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("span", { className: "min-w-0 truncate text-right", children: w.absent ? w.absent === "conflicting" ? "Sources disagree" : "Nothing found" : String(w.value ?? "") })
29709
29721
  ] }, w.record_id)) }) : null,
29710
- outcome && (outcome.fieldId === void 0 || outcome.fieldId === row.field_id) ? outcome.ok ? /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)("p", { className: "text-xs text-muted-foreground", "data-testid": "enrich-outcome", children: [
29711
- outcome.message,
29712
- costInPoints(outcome.costCents, host.pointsRate) !== null ? ` \xB7 ${costInPoints(outcome.costCents, host.pointsRate)}` : ""
29713
- ] }) : (
29722
+ outcome && (outcome.fieldId === void 0 || outcome.fieldId === row.field_id) ? outcome.ok ? /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("p", { className: "text-xs text-muted-foreground", "data-testid": "enrich-outcome", children: outcome.message }) : (
29714
29723
  // A run that did not happen is a refusal, with a heading and a remedy,
29715
29724
  // never the host's words in red (lane REFUSAL-SWEEP).
29716
29725
  /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
@@ -41425,7 +41434,7 @@ function useRowColorBy(all, colorKey, style) {
41425
41434
  // src/workedOutDate.ts
41426
41435
  var import_records55 = require("@ai-matrx/records");
41427
41436
  var WORKED_OUT_DATE_LOCK = "Worked out \xB7 can't move";
41428
- var INLINE_DEPTH = 8;
41437
+ var FORMULA_TYPING_ROUNDS = 9;
41429
41438
  var configOf = (field2) => field2?.config ?? {};
41430
41439
  function isStoredDate(field2) {
41431
41440
  if (!field2 || field2.type !== "range") return false;
@@ -41439,27 +41448,36 @@ function ownExpression(field2) {
41439
41448
  const expr = config["expr"];
41440
41449
  return !("via" in config) && expr && typeof expr === "object" && !Array.isArray(expr) ? expr : null;
41441
41450
  }
41442
- function inlineFormulas(node, all, seen = []) {
41443
- if (!node || typeof node !== "object" || Array.isArray(node)) return node;
41444
- const n = node;
41445
- if ("field" in n) {
41446
- const f = all.find((x) => x.id === n["field"]);
41447
- const expr = ownExpression(f);
41448
- if (!expr) return node;
41449
- const id = String(n["field"]);
41450
- if (seen.includes(id) || seen.length >= INLINE_DEPTH) return null;
41451
- return inlineFormulas(expr, all, [...seen, id]);
41451
+ function typedAs(field2, kind2) {
41452
+ if (kind2 === "date") return { ...field2, type: "range", config: { kind: "date", _typed: true } };
41453
+ if (kind2 === "number") return { ...field2, type: "range", config: { _typed: true } };
41454
+ if (kind2 === "text") return { ...field2, type: "text" };
41455
+ if (kind2 === "boolean") return { ...field2, type: "boolean" };
41456
+ return field2;
41457
+ }
41458
+ var typedRounds = /* @__PURE__ */ new WeakMap();
41459
+ function typedFormulaFields(all, rounds = FORMULA_TYPING_ROUNDS) {
41460
+ let byRounds = typedRounds.get(all);
41461
+ const hit = byRounds?.get(rounds);
41462
+ if (hit) return hit;
41463
+ let cur = all;
41464
+ for (let i = 0; i < rounds; i++) {
41465
+ const prev = cur;
41466
+ cur = all.map((f) => {
41467
+ const expr = ownExpression(f);
41468
+ return expr ? typedAs(f, formulaResultKind(expr, prev)) : f;
41469
+ });
41452
41470
  }
41453
- if (Array.isArray(n["args"])) {
41454
- const args = [];
41455
- for (const a of n["args"]) {
41456
- const r = inlineFormulas(a, all, seen);
41457
- if (r === null) return null;
41458
- args.push(r);
41459
- }
41460
- return { ...n, args };
41471
+ if (!byRounds) {
41472
+ byRounds = /* @__PURE__ */ new Map();
41473
+ typedRounds.set(all, byRounds);
41461
41474
  }
41462
- return node;
41475
+ byRounds.set(rounds, cur);
41476
+ return cur;
41477
+ }
41478
+ function formulaTypeOf(targetId, all, rounds = FORMULA_TYPING_ROUNDS) {
41479
+ const expr = ownExpression(all.find((f) => f.id === targetId));
41480
+ return expr ? formulaResultKind(expr, typedFormulaFields(all, rounds)) : "unknown";
41463
41481
  }
41464
41482
  function formulaResultKind(node, all) {
41465
41483
  if (!node || typeof node !== "object" || Array.isArray(node)) return "unknown";
@@ -41498,10 +41516,7 @@ function formulaResultKind(node, all) {
41498
41516
  return import_records55.FORMULA_NODE_RESULTS[op2] ?? "unknown";
41499
41517
  }
41500
41518
  function isDateFormula(field2, all) {
41501
- const expr = ownExpression(field2);
41502
- if (!expr || !field2) return false;
41503
- const inlined = inlineFormulas(expr, all, [field2.id]);
41504
- return inlined !== null && formulaResultKind(inlined, all) === "date";
41519
+ return !!field2 && formulaTypeOf(field2.id, all) === "date";
41505
41520
  }
41506
41521
  function isComputedField(field2) {
41507
41522
  return field2?.type === "formula";
@@ -56363,7 +56378,6 @@ function QuestionAnswerView({ tableId, spec, answer, fields, related = NO_RELATE
56363
56378
 
56364
56379
  // src/TableAsk.tsx
56365
56380
  var import_react315 = require("react");
56366
- var import_format14 = require("@ai-matrx/kit/format");
56367
56381
  var import_design_system157 = require("@ai-matrx/design-system");
56368
56382
  var import_records68 = require("@ai-matrx/records");
56369
56383
  var import_react316 = require("@ai-matrx/records/react");
@@ -56604,7 +56618,7 @@ function TableAsk({ tableId, onOpenInQuestions, viewId }) {
56604
56618
  setSaid({ kind: "asking", reads: words2.trim() });
56605
56619
  const got = await askTable({ tableId, question: words2.trim(), viewId: viewId ?? "" });
56606
56620
  setSaid(
56607
- got.ok ? { kind: "agent-answer", answer: got.answer, costPoints: got.costPoints ?? null } : { kind: "agent-failed", error: (0, refusals_exports.refusal)("door", got.message, got.hint ?? null) }
56621
+ got.ok ? { kind: "agent-answer", answer: got.answer } : { kind: "agent-failed", error: (0, refusals_exports.refusal)("door", got.message, got.hint ?? null) }
56608
56622
  );
56609
56623
  return;
56610
56624
  }
@@ -56657,7 +56671,7 @@ function TableAsk({ tableId, onOpenInQuestions, viewId }) {
56657
56671
  /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(import_design_system157.Skeleton, { className: "h-24 w-full", "data-table-ask-pending": "" })
56658
56672
  ] }) : null,
56659
56673
  said2.kind === "agent-failed" ? /* @__PURE__ */ (0, import_jsx_runtime180.jsx)("div", { "data-table-ask-failed": "", children: /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(RefusalNotice, { error: said2.error }) }) : null,
56660
- said2.kind === "agent-answer" ? /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(AgentAnswer, { tableId, answer: said2.answer, fields: all, costPoints: said2.costPoints }) : null,
56674
+ said2.kind === "agent-answer" ? /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(AgentAnswer, { tableId, answer: said2.answer, fields: all }) : null,
56661
56675
  said2.kind === "refused" ? /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(RefusalNotice, { error: said2.error }) : null,
56662
56676
  said2.kind === "answer" ? /* @__PURE__ */ (0, import_jsx_runtime180.jsxs)(import_jsx_runtime180.Fragment, { children: [
56663
56677
  /* @__PURE__ */ (0, import_jsx_runtime180.jsx)("p", { className: "truncate text-muted-foreground", title: said2.reads, "data-table-ask-reads": "", children: said2.reads }),
@@ -56706,8 +56720,7 @@ function useNames(tableId, ids) {
56706
56720
  function AgentAnswer({
56707
56721
  tableId,
56708
56722
  answer,
56709
- fields,
56710
- costPoints = null
56723
+ fields
56711
56724
  }) {
56712
56725
  const client = (0, import_react316.useRecordsClient)();
56713
56726
  const ui = useRecordsUi();
@@ -56773,7 +56786,6 @@ function AgentAnswer({
56773
56786
  ] }, `${c.record_id}:${c.field_key}:${i}`)) }) : null,
56774
56787
  open.length > 1 ? /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(import_design_system157.Button, { size: "sm", className: "w-fit self-end", disabled: busy, onClick: () => void apply(open), "data-table-ask-apply-all": "", children: "Apply all" }) : null,
56775
56788
  refusal3 ? /* @__PURE__ */ (0, import_jsx_runtime180.jsx)(RefusalNotice, { error: refusal3 }) : null,
56776
- costPoints !== null ? /* @__PURE__ */ (0, import_jsx_runtime180.jsx)("p", { className: "text-muted-foreground", "data-table-ask-cost": "", children: (0, import_format14.formatPoints)(costPoints) }) : null,
56777
56789
  answer.could_not.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime180.jsx)("ul", { className: "text-muted-foreground", "data-table-ask-could-not": "", children: answer.could_not.map((w) => /* @__PURE__ */ (0, import_jsx_runtime180.jsx)("li", { children: w }, w)) }) : null
56778
56790
  ] });
56779
56791
  }
@@ -56791,7 +56803,7 @@ var import_react317 = require("react");
56791
56803
  var import_react318 = require("@ai-matrx/records/react");
56792
56804
  var import_core25 = require("@ai-matrx/records/core");
56793
56805
  var import_download3 = require("@ai-matrx/kit/download");
56794
- var import_format15 = require("@ai-matrx/kit/format");
56806
+ var import_format14 = require("@ai-matrx/kit/format");
56795
56807
  var import_design_system158 = require("@ai-matrx/design-system");
56796
56808
  init_parity();
56797
56809
  var import_forms4 = require("@ai-matrx/records/forms");
@@ -57295,7 +57307,7 @@ function NumberBlockView({ block, viewerUserId, extra }) {
57295
57307
  const read = useElementRows(block, viewerUserId, extra, false);
57296
57308
  if (read.error) return /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(RefusalLine, { error: read.error });
57297
57309
  if (read.waiting || read.total === null) return /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(import_design_system158.Skeleton, { className: "h-12 w-24" });
57298
- return /* @__PURE__ */ (0, import_jsx_runtime181.jsx)("p", { className: "text-3xl font-semibold tabular-nums", "data-records-page-number": block.id, children: (0, import_format15.formatCount)(read.total) });
57310
+ return /* @__PURE__ */ (0, import_jsx_runtime181.jsx)("p", { className: "text-3xl font-semibold tabular-nums", "data-records-page-number": block.id, children: (0, import_format14.formatCount)(read.total) });
57299
57311
  }
57300
57312
  function LayoutBlockView({ block, viewerUserId, extra }) {
57301
57313
  const door = useInterfaceDoor();
@@ -60085,7 +60097,7 @@ function TableReferenceDialog({
60085
60097
  }
60086
60098
 
60087
60099
  // src/TableDuplicate.tsx
60088
- var import_format16 = require("@ai-matrx/kit/format");
60100
+ var import_format15 = require("@ai-matrx/kit/format");
60089
60101
  var import_react340 = require("react");
60090
60102
  var import_react341 = require("@ai-matrx/records/react");
60091
60103
  var import_design_system171 = require("@ai-matrx/design-system");
@@ -60096,7 +60108,7 @@ function copyNameFor(name) {
60096
60108
  return `${name.trim() || "Table"} (copy)`;
60097
60109
  }
60098
60110
  function duplicateProgressWords(p) {
60099
- if (p.records && p.records.total > 0) return `Copying records \xB7 ${(0, import_format16.formatCount)(p.records.done)} of ${(0, import_format16.formatCount)(p.records.total)}`;
60111
+ if (p.records && p.records.total > 0) return `Copying records \xB7 ${(0, import_format15.formatCount)(p.records.done)} of ${(0, import_format15.formatCount)(p.records.total)}`;
60100
60112
  if (p.views.total > 0 && p.step === "views") return `Copying views \xB7 ${p.views.done} of ${p.views.total}`;
60101
60113
  return "Copying columns\u2026";
60102
60114
  }
@@ -60153,7 +60165,7 @@ function TableDuplicateDialog({ tableId, name, organizationId, open, onOpenChang
60153
60165
  " columns, ",
60154
60166
  phase.copy.copied.views,
60155
60167
  " views",
60156
- phase.copy.copied.withRecords ? `, ${(0, import_format16.formatCount)(phase.copy.copied.records)} records` : "",
60168
+ phase.copy.copied.withRecords ? `, ${(0, import_format15.formatCount)(phase.copy.copied.records)} records` : "",
60157
60169
  "."
60158
60170
  ] }),
60159
60171
  phase.copy.notCopied.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime194.jsxs)("p", { className: "text-xs text-muted-foreground", children: [
@@ -62283,7 +62295,7 @@ function usePublicReadOnly(client, organizationId, tableId, table, rights) {
62283
62295
  }
62284
62296
 
62285
62297
  // src/entityViews.tsx
62286
- var import_format17 = require("@ai-matrx/kit/format");
62298
+ var import_format16 = require("@ai-matrx/kit/format");
62287
62299
  var import_design_system175 = require("@ai-matrx/design-system");
62288
62300
  var import_data_table26 = require("@ai-matrx/design-system/data-table");
62289
62301
  var import_react348 = require("react");
@@ -62478,7 +62490,7 @@ function EntityTablePageBody({
62478
62490
  return /* @__PURE__ */ (0, import_jsx_runtime199.jsxs)("div", { className: (0, import_design_system176.cn)("flex min-w-0 flex-col gap-2", className), "data-records-entity-page": source.token, children: [
62479
62491
  presentation === "page" || boardable || entity.creatable ? /* @__PURE__ */ (0, import_jsx_runtime199.jsxs)("div", { className: "flex min-w-0 items-center gap-2", children: [
62480
62492
  presentation === "page" ? /* @__PURE__ */ (0, import_jsx_runtime199.jsx)("h2", { className: "truncate text-base font-semibold", children: entity.label ?? (entity.loading ? "Loading\u2026" : "Table") }) : null,
62481
- presentation === "page" ? /* @__PURE__ */ (0, import_jsx_runtime199.jsx)("span", { className: "text-xs tabular-nums text-muted-foreground", children: entity.loading || entity.total === null ? "" : (0, import_format17.formatCount)(entity.total) }) : null,
62493
+ presentation === "page" ? /* @__PURE__ */ (0, import_jsx_runtime199.jsx)("span", { className: "text-xs tabular-nums text-muted-foreground", children: entity.loading || entity.total === null ? "" : (0, import_format16.formatCount)(entity.total) }) : null,
62482
62494
  /* @__PURE__ */ (0, import_jsx_runtime199.jsxs)("span", { className: "ml-auto flex items-center gap-1", children: [
62483
62495
  boardable ? /* @__PURE__ */ (0, import_jsx_runtime199.jsxs)(import_jsx_runtime199.Fragment, { children: [
62484
62496
  /* @__PURE__ */ (0, import_jsx_runtime199.jsx)(import_design_system176.Button, { size: "sm", variant: layout === "grid" ? "secondary" : "ghost", "aria-pressed": layout === "grid", onClick: () => choose("grid"), children: "Table" }),