@ai-matrx/records-ui 0.116.109 → 0.116.110

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/CHANGELOG.md CHANGED
@@ -1,10 +1,20 @@
1
1
  # Changelog
2
2
 
3
- ## 0.116.109
3
+ ## 0.116.110
4
4
 
5
5
  UNVERIFIED: this release has no Unreleased entry and the source comparison could not be made (the caller supplied no source comparison). Whether source changed is unknown; consumer action is unknown.
6
6
  Check the package's gitHead on npm against this version's gitHead: `git diff <previous gitHead> <this gitHead> -- apps/shared/records-ui/src`.
7
7
 
8
+ ## 0.116.109
9
+
10
+ SOURCE CHANGED WITH NO RELEASE NOTE. This release shipped source changes that nobody described in an Unreleased entry,
11
+ so they may include breaking API changes. Consumer action is UNKNOWN: read the diff before upgrading.
12
+ Diff: `git diff d324df1734 5a535efe67 -- apps/shared/records-ui/src`
13
+
14
+ Changed shipped source files (2):
15
+ - `apps/shared/records-ui/src/DocRender.tsx`
16
+ - `apps/shared/records-ui/src/DocTemplate.tsx`
17
+
8
18
  ## 0.116.108
9
19
 
10
20
  Automatic changed-only republish (docs/metadata drift since the last published version; verified: `git diff 45e5dca239 d324df1734 -- apps/shared/records-ui/src`
package/dist/index.cjs CHANGED
@@ -26045,6 +26045,7 @@ function EnrichPanel({ tableId, fieldId, className }) {
26045
26045
  });
26046
26046
  const chosen = setup.preset ? (0, import_records42.aiFieldPreset)(setup.preset) : void 0;
26047
26047
  const readsPictures = (0, import_records42.presetInputs)(setup.preset, attachmentColumns.map((f) => f.key));
26048
+ const readsRecord = readsPictures ?? (0, import_records42.defaultEnrichInputs)(fields.data ?? [], target?.key ?? "");
26048
26049
  const applyPreset = (preset, answer) => {
26049
26050
  const reads = preset === "describe_image" ? attachmentColumns.map((f) => f.name ?? f.label) : void 0;
26050
26051
  const sentence2 = (0, import_records42.presetInstruction)(preset, { answer, reads });
@@ -26129,7 +26130,7 @@ function EnrichPanel({ tableId, fieldId, className }) {
26129
26130
  review_interval_days: setup.every ? Number(setup.every) : null,
26130
26131
  enabled: false,
26131
26132
  // Describe image reads the table's attachment columns: name them, or the model is shown nothing.
26132
- ...readsPictures ? { inputs: readsPictures } : {}
26133
+ ...readsRecord.length > 0 ? { inputs: readsRecord } : {}
26133
26134
  }
26134
26135
  ),
26135
26136
  children: "Set it up"
@@ -32476,7 +32477,7 @@ init_refusals();
32476
32477
  var import_jsx_runtime104 = require("react/jsx-runtime");
32477
32478
  function keptWhileAway(outcome, readBackUnsent, readBackRefusal) {
32478
32479
  if (!readBackUnsent || outcome.written === 0) return outcome;
32479
- const values = outcome.readBack + outcome.missing;
32480
+ const values = outcome.readBack + outcome.missing + (outcome.waiting ?? 0);
32480
32481
  return {
32481
32482
  ...outcome,
32482
32483
  readBack: 0,
@@ -32488,7 +32489,9 @@ function keptWhileAway(outcome, readBackUnsent, readBackRefusal) {
32488
32489
  function outcomeSentence(outcome) {
32489
32490
  const waiting = outcome.waiting ?? 0;
32490
32491
  if (waiting > 0) {
32491
- return `${waiting} ${waiting === 1 ? "value is" : "values are"} saved on this computer and will be sent to the table when you are back online.`;
32492
+ const kept2 = `${waiting} ${waiting === 1 ? "value is" : "values are"} saved on this computer and will be sent to the table when you are back online.`;
32493
+ const rest = outcome.missing > 0 ? ` ${outcome.missing} could not be found afterwards.` : "";
32494
+ return outcome.readBack > 0 ? `${outcome.readBack} in the table. ${kept2}${rest}` : `${kept2}${rest}`;
32492
32495
  }
32493
32496
  const whole = outcome.missing === 0 && outcome.refusals.length === 0;
32494
32497
  return whole ? `All ${outcome.readBack} ${outcome.readBack === 1 ? "value is" : "values are"} in the table \u2014 read back out of it, not just accepted.` : `${outcome.readBack} of ${outcome.readBack + outcome.missing} values are in the table. The rest are not, and nothing was lost from what you copied \u2014 it is still on your clipboard.`;
@@ -35940,15 +35943,19 @@ function GridBody({
35940
35943
  const readBackRefusal = reread.ok ? void 0 : `The rows were written and this could not read them back to check: ${refusalSentence(reread.error)}`;
35941
35944
  if (readBackRefusal !== void 0) refusals.push(readBackRefusal);
35942
35945
  const seen = new Map((reread.ok ? reread.data : []).map((r) => [r.id, r.document ?? {}]));
35946
+ const unsent = new Set((reread.ok ? reread.data : []).filter((r) => r.waiting).map((r) => r.id));
35947
+ let waiting = 0;
35943
35948
  for (const entry of expected) {
35944
35949
  const stored = seen.get(entry.recordId);
35945
35950
  for (const [key, value] of Object.entries(entry.document)) {
35946
- if (stored !== void 0 && storedValueAgrees(fieldOf2.get(key), stored[key], value, choiceOptions.current.get(key))) readBack += 1;
35947
- else missing += 1;
35951
+ if (stored !== void 0 && storedValueAgrees(fieldOf2.get(key), stored[key], value, choiceOptions.current.get(key))) {
35952
+ if (unsent.has(entry.recordId)) waiting += 1;
35953
+ else readBack += 1;
35954
+ } else missing += 1;
35948
35955
  }
35949
35956
  }
35950
35957
  records.reload();
35951
- return keptWhileAway({ written: lines2, readBack, missing, refusals }, !reread.ok && isUnsentWrite(reread.error), readBackRefusal);
35958
+ return keptWhileAway({ written: lines2, readBack, missing, refusals, waiting }, !reread.ok && isUnsentWrite(reread.error), readBackRefusal);
35952
35959
  },
35953
35960
  [rows, client, tableId, editing, undo, records, versions, fields.data]
35954
35961
  );
@@ -36027,6 +36034,8 @@ function GridBody({
36027
36034
  let missing = 0;
36028
36035
  const fieldOf2 = new Map((fields.data ?? []).map((f) => [f.key, f]));
36029
36036
  const seen = /* @__PURE__ */ new Map();
36037
+ const unsent = /* @__PURE__ */ new Set();
36038
+ let waiting = 0;
36030
36039
  const READ_BACK_PAGE = 500;
36031
36040
  let readBackRefusal;
36032
36041
  let readBackUnsent = false;
@@ -36040,6 +36049,7 @@ function GridBody({
36040
36049
  }
36041
36050
  for (const row of reread.data.rows) {
36042
36051
  seen.set(row.id, row.document ?? {});
36052
+ if (row.waiting) unsent.add(row.id);
36043
36053
  }
36044
36054
  if (reread.data.rows.length + (reread.data.locked ?? 0) < READ_BACK_PAGE) break;
36045
36055
  if (expected.every((e) => seen.has(e.recordId))) break;
@@ -36048,14 +36058,15 @@ function GridBody({
36048
36058
  const stored = seen.get(entry.recordId);
36049
36059
  for (const [key, value] of Object.entries(entry.document)) {
36050
36060
  if (stored !== void 0 && storedValueAgrees(fieldOf2.get(key), stored[key], value, choiceOptions.current.get(key))) {
36051
- readBack += 1;
36061
+ if (unsent.has(entry.recordId)) waiting += 1;
36062
+ else readBack += 1;
36052
36063
  } else {
36053
36064
  missing += 1;
36054
36065
  }
36055
36066
  }
36056
36067
  }
36057
36068
  records.reload();
36058
- return keptWhileAway({ written, readBack, missing, refusals }, readBackUnsent, readBackRefusal);
36069
+ return keptWhileAway({ written, readBack, missing, refusals, waiting }, readBackUnsent, readBackRefusal);
36059
36070
  }, [pastePlan, client, tableId, records, merged, applyPasteAsOne, versions, fields.data]);
36060
36071
  const columnIds = (0, import_react197.useMemo)(() => ordered.map((field2) => field2.key), [ordered]);
36061
36072
  const lookWrites = (0, import_react197.useRef)(null);
@@ -38761,7 +38772,8 @@ var VERB_WORDS = {
38761
38772
  rename: "Renamed",
38762
38773
  delete: "Removed"
38763
38774
  };
38764
- function migrationWords(verb) {
38775
+ function migrationWords(verb, targetKind) {
38776
+ if (verb === "retype" && targetKind === "record") return "Moved to another table";
38765
38777
  return VERB_WORDS[verb] ?? (0, import_text_case19.humanizeIdentifier)(verb);
38766
38778
  }
38767
38779
  function useMigrationLog(recordId) {
@@ -38814,12 +38826,12 @@ function MigrationLog({ entries, readError, canUndo, whyNotUndo, onUndone, class
38814
38826
  return;
38815
38827
  }
38816
38828
  const removed = back.data.removed ? " The record it made is archived, so no copy is left behind." : "";
38817
- await onUndone(`${migrationWords(entry.verb)} undone.${removed}`);
38829
+ await onUndone(`${migrationWords(entry.verb, entry.target_kind)} undone.${removed}`);
38818
38830
  }
38819
38831
  return /* @__PURE__ */ (0, import_jsx_runtime131.jsxs)("section", { "aria-label": "Migration log", className: (0, import_design_system111.cn)("flex flex-col gap-1", className), "data-records-migration-log": "", children: [
38820
38832
  /* @__PURE__ */ (0, import_jsx_runtime131.jsx)("h4", { className: "text-xs font-medium", children: "Migration log" }),
38821
38833
  /* @__PURE__ */ (0, import_jsx_runtime131.jsx)("ul", { className: "flex flex-col divide-y rounded border text-xs", children: entries.map((entry) => /* @__PURE__ */ (0, import_jsx_runtime131.jsxs)("li", { "data-migration-id": entry.id, className: "flex items-center gap-2 px-2 py-1.5", children: [
38822
- /* @__PURE__ */ (0, import_jsx_runtime131.jsx)("span", { className: "shrink-0 font-medium", children: migrationWords(entry.verb) }),
38834
+ /* @__PURE__ */ (0, import_jsx_runtime131.jsx)("span", { className: "shrink-0 font-medium", children: migrationWords(entry.verb, entry.target_kind) }),
38823
38835
  /* @__PURE__ */ (0, import_jsx_runtime131.jsx)("span", { className: "min-w-0 flex-1 truncate text-muted-foreground", title: entry.note ? withoutInternalCodes(entry.note) : void 0, children: entry.note ? withoutInternalCodes(entry.note) : "" }),
38824
38836
  /* @__PURE__ */ (0, import_jsx_runtime131.jsx)("span", { className: "min-w-28 shrink-0 whitespace-nowrap text-right text-muted-foreground", title: new Date(entry.applied_at).toLocaleString(), children: whenText(entry.applied_at) }),
38825
38837
  entry.undone_at ? /* @__PURE__ */ (0, import_jsx_runtime131.jsx)("span", { className: "w-14 shrink-0 text-right text-muted-foreground", children: "Undone" }) : canUndo ? /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(
@@ -39003,6 +39015,7 @@ function HistoryPanel({ tableId, recordId, onAskAboutField, className }) {
39003
39015
  VersionRow,
39004
39016
  {
39005
39017
  entry,
39018
+ madeBy: entry.migration_id ? (shape.entries ?? []).find((m) => m.id === entry.migration_id) ?? null : null,
39006
39019
  byKey,
39007
39020
  expanded: open === entry.version,
39008
39021
  onToggle: () => setOpen(open === entry.version ? null : entry.version),
@@ -39036,6 +39049,7 @@ function HistoryPanel({ tableId, recordId, onAskAboutField, className }) {
39036
39049
  }
39037
39050
  function VersionRow({
39038
39051
  entry,
39052
+ madeBy,
39039
39053
  byKey,
39040
39054
  expanded,
39041
39055
  onToggle,
@@ -39087,7 +39101,7 @@ function VersionRow({
39087
39101
  children: [
39088
39102
  /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)("span", { className: "flex min-w-0 items-baseline gap-1.5", children: [
39089
39103
  /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(Who, { actor: entry.actor, changes: entry.changes }),
39090
- /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("span", { className: "shrink-0 text-muted-foreground", children: verbWords(operationWords(entry.operation_label)) }),
39104
+ /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("span", { className: "shrink-0 text-muted-foreground", children: verbWords(madeBy ? migrationWords(madeBy.verb, madeBy.target_kind) : operationWords(entry.operation_label)) }),
39091
39105
  entry.undoable ? /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(import_design_system112.Badge, { variant: "secondary", className: "min-w-0 shrink truncate text-[10px]", title: "part of a bigger change", children: "part of a bigger change" }) : null,
39092
39106
  /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)("span", { className: "ml-auto flex shrink-0 items-baseline gap-1.5 whitespace-nowrap text-muted-foreground", children: [
39093
39107
  /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)("span", { className: "tabular-nums", children: [
@@ -39198,9 +39212,9 @@ function ChangeLine({
39198
39212
  return /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)("li", { "data-change-key": change.key, className: "flex items-baseline gap-2 text-[11px]", children: [
39199
39213
  /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("span", { className: "w-24 shrink-0 truncate font-medium", title: change.label, children: change.label || (0, import_text_case20.humanizeIdentifier)(change.key) }),
39200
39214
  /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)("span", { className: "min-w-0 flex-1 truncate", children: [
39201
- /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("span", { className: "text-muted-foreground line-through", children: say(change.before, field2) }),
39215
+ /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("span", { className: "text-muted-foreground line-through", children: change.before_words ?? say(change.before, field2) }),
39202
39216
  /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("span", { className: "mx-1 text-muted-foreground", children: "\u2192" }),
39203
- /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("strong", { className: "font-medium", children: say(change.after, field2) })
39217
+ /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("strong", { className: "font-medium", children: change.after_words ?? say(change.after, field2) })
39204
39218
  ] }),
39205
39219
  change.rule ? /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)(import_design_system112.Badge, { variant: "outline", className: "shrink-0 text-[10px]", title: "Worked out by a rule", children: [
39206
39220
  "rule v",
@@ -39288,9 +39302,9 @@ function ConfirmRestore({
39288
39302
  /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("ul", { className: "flex flex-col gap-0.5", children: preview.changes.map((change) => /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)("li", { className: "text-[11px]", children: [
39289
39303
  /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("span", { className: "font-medium", children: change.label }),
39290
39304
  " ",
39291
- /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("span", { className: "text-muted-foreground", children: say(change.before, void 0) }),
39305
+ /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("span", { className: "text-muted-foreground", children: change.before_words ?? say(change.before, void 0) }),
39292
39306
  /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("span", { className: "mx-1 text-muted-foreground", children: "\u2192" }),
39293
- /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("strong", { className: "font-medium", children: change.after === null || change.after === void 0 ? "cleared" : say(change.after, void 0) })
39307
+ /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("strong", { className: "font-medium", children: change.after === null || change.after === void 0 ? "cleared" : change.after_words ?? say(change.after, void 0) })
39294
39308
  ] }, change.key)) }),
39295
39309
  /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "It is saved as a new version. Nothing in the history is erased, and this can be put back too." }),
39296
39310
  /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)("div", { className: "flex gap-1", children: [
@@ -40699,10 +40713,14 @@ function RecordPanel({ tableId, recordId, onClose, onAskAboutField, onPage = fal
40699
40713
  const record = (0, import_react230.useRecord)(recordId, true, { tableId });
40700
40714
  const answered = Boolean(record.data) && !record.error;
40701
40715
  const panelRef = (0, import_react229.useRef)(null);
40716
+ const opened = (0, import_react229.useRef)(false);
40702
40717
  (0, import_react229.useEffect)(() => {
40703
40718
  if (onPage) return;
40704
40719
  const panel = panelRef.current;
40720
+ const first = !opened.current;
40721
+ opened.current = true;
40705
40722
  if (!panel || panel.contains(document.activeElement)) return;
40723
+ if (!first && document.activeElement instanceof Element && document.activeElement.closest("[data-matrx-table-spreadsheet]")) return;
40706
40724
  panel.focus({ preventScroll: true });
40707
40725
  }, [recordId, onPage]);
40708
40726
  return /* @__PURE__ */ (0, import_jsx_runtime138.jsxs)(
@@ -51298,6 +51316,8 @@ function ViewBar({ tableId, activeViewId, onActiveView, seed, settings, onViews,
51298
51316
  if (!claimSeed(spec.name)) continue;
51299
51317
  const written = await declareView(client, { ...spec, subject: tableId });
51300
51318
  if (!written.ok) {
51319
+ const now = await readViews();
51320
+ if (now.ok && seedIsSatisfied(spec, now.data)) continue;
51301
51321
  setError(written.error);
51302
51322
  onViews?.(null);
51303
51323
  return;
@@ -66698,6 +66718,7 @@ var import_design_system197 = require("@ai-matrx/design-system");
66698
66718
  var import_icons5 = require("@ai-matrx/design-system/icons");
66699
66719
  var import_field_formats24 = require("@ai-matrx/design-system/field-formats");
66700
66720
  var import_controls30 = require("@ai-matrx/design-system/controls");
66721
+ var import_first_page10 = require("@ai-matrx/records/first-page");
66701
66722
  init_names();
66702
66723
  init_plainWords();
66703
66724
 
@@ -67032,16 +67053,22 @@ function sectionColumns(fields, titleField, props) {
67032
67053
  return { name, group, note, readsOn, values };
67033
67054
  }
67034
67055
  var NATURAL2 = new Intl.Collator(void 0, { numeric: true, sensitivity: "base" });
67035
- function orderedRows(rows, nameKey) {
67056
+ function orderedRows(rows, nameKey, direction = "asc") {
67036
67057
  if (!nameKey) return [...rows];
67037
67058
  const nameOf3 = (r) => String((r.document ?? {})[nameKey] ?? "");
67059
+ const sign = direction === "desc" ? -1 : 1;
67038
67060
  return [...rows].sort((a, b) => {
67039
67061
  const x = nameOf3(a);
67040
67062
  const y = nameOf3(b);
67041
67063
  if (x === "" || y === "") return x === "" ? y === "" ? 0 : 1 : -1;
67042
- return NATURAL2.compare(x, y);
67064
+ return sign * NATURAL2.compare(x, y);
67043
67065
  });
67044
67066
  }
67067
+ function tableSortedRows(rows, sort, fields) {
67068
+ const field2 = fields.find((f) => f.key === sort.id);
67069
+ if (!field2 || (0, import_first_page10.sortAsFor)(field2) !== "text") return [...rows];
67070
+ return orderedRows(rows, sort.id, sort.direction);
67071
+ }
67045
67072
  function sectionGroups(rows, groupKey) {
67046
67073
  if (!groupKey) return [{ key: UNGROUPED2, rows: [...rows] }];
67047
67074
  const map = /* @__PURE__ */ new Map();
@@ -67434,7 +67461,6 @@ function TableSectionCard(props) {
67434
67461
  const fieldsRead = (0, import_react392.useFields)(tableId);
67435
67462
  const tableSort = (0, import_first_page3.defaultSortOf)(table.data ?? null, fieldsRead.data ?? []);
67436
67463
  const page = (0, import_react392.useRecordPage)(fieldsRead.data ? tableId : null, { pageSize: 200, ...tableSort ? { sort: [{ field: tableSort.id, direction: tableSort.direction }] } : {} });
67437
- const sortedByStore = tableSort !== null;
67438
67464
  const mutation = (0, import_react392.useRecordMutation)();
67439
67465
  const [adding, setAdding] = (0, import_react391.useState)(null);
67440
67466
  const [failed, setFailed] = (0, import_react391.useState)(null);
@@ -67446,7 +67472,7 @@ function TableSectionCard(props) {
67446
67472
  const readsOnField = cols.readsOn ? fields.find((f) => f.key === cols.readsOn) : void 0;
67447
67473
  const readsOnColorKey = cols.readsOn ? cols.values.find((f) => formatForField(f)?.options?.contrastWith?.readsOnField === cols.readsOn)?.key : void 0;
67448
67474
  const columns = columnsOf(cols.values);
67449
- const rows = sortedByStore ? page.data?.rows ?? [] : orderedRows(page.data?.rows ?? [], cols.name);
67475
+ const rows = tableSort ? tableSortedRows(page.data?.rows ?? [], tableSort, fields) : orderedRows(page.data?.rows ?? [], cols.name);
67450
67476
  const groups = sectionGroups(rows, cols.group);
67451
67477
  const level = rows[0]?.level ?? null;
67452
67478
  const mayWrite = !readOnly && (rows.length === 0 ? !readOnly : (0, import_field_kinds9.atLeast)(level, "edit_content"));