@ai-matrx/records-ui 0.95.14 → 0.95.16

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,5 +1,17 @@
1
1
  # Changelog — @ai-matrx/records-ui
2
2
 
3
+ ## 0.95.16
4
+
5
+ Automatic changed-only republish (docs/metadata drift since the last tag — see
6
+ `git diff npm/records-ui/v0.95.15..npm/records-ui/v0.95.16 -- apps/shared/records-ui`).
7
+ No source changes intended and no consumer action required.
8
+
9
+ ## 0.95.15
10
+
11
+ Automatic changed-only republish (docs/metadata drift since the last tag — see
12
+ `git diff npm/records-ui/v0.95.14..npm/records-ui/v0.95.15 -- apps/shared/records-ui`).
13
+ No source changes intended and no consumer action required.
14
+
3
15
  ## 0.95.14
4
16
 
5
17
  Automatic changed-only republish (docs/metadata drift since the last tag — see
package/dist/index.cjs CHANGED
@@ -7559,6 +7559,11 @@ function tableArchiveSentence(s) {
7559
7559
  if (s.interrupted) return `Stopped: ${sofar}. Carry on whenever you like; it picks up where it stopped.`;
7560
7560
  return `Its ${recordsWord(p.remaining)} ${p.remaining === 1 ? "goes" : "go"} with it.`;
7561
7561
  }
7562
+ function readersSentence(count, tableName2) {
7563
+ if (count <= 0) return "";
7564
+ const rollups = count === 1 ? "1 rollup" : `${count} rollups`;
7565
+ return `${rollups} on ${tableName2 ?? "this table"} read through this.`;
7566
+ }
7562
7567
 
7563
7568
  // src/tableDecorations.ts
7564
7569
  var import_react36 = require("react");
@@ -10825,9 +10830,15 @@ function FieldEditor(props) {
10825
10830
  const reverse = (0, import_react61.useReverseColumns)(onEntity ? null : tableId);
10826
10831
  const backLinks = (0, import_react60.useMemo)(() => (reverse.data ?? []).map(backLinkAsSource), [reverse.data]);
10827
10832
  const totalSources = (0, import_react60.useMemo)(() => [...relations, ...backLinks], [relations, backLinks]);
10828
- const sourcesFor = (kind) => kind === "rollup" ? totalSources : relations;
10833
+ const sourcesFor = (kind) => kind === "rollup" || kind === "count" ? totalSources : relations;
10829
10834
  const choice = fieldTypeChoice(type);
10830
10835
  const editing = Boolean(field2);
10836
+ const farFieldsOfLink = (0, import_react61.useFields)(field2 && sourceKindOf(field2) === "link" && !onEntity ? field2.relation_target ?? null : null);
10837
+ const farTable = (0, import_react61.useTable)(field2 && sourceKindOf(field2) === "link" && !onEntity ? field2.relation_target ?? null : null);
10838
+ const linkReaders = (0, import_react60.useMemo)(
10839
+ () => field2 ? readingThroughLink(field2, farFieldsOfLink.data ?? []) : [],
10840
+ [field2, farFieldsOfLink.data]
10841
+ );
10831
10842
  const isTitle = Boolean(field2) && !onEntity && table.data?.title_field === field2?.key;
10832
10843
  const offersMany = multiApplies(type) && !isTitle;
10833
10844
  if (!mayShape) {
@@ -10843,7 +10854,7 @@ function FieldEditor(props) {
10843
10854
  const noun = onEntity ? "field" : "column";
10844
10855
  const listsChoices = type === "select" || type === "multi_select" || type === "status";
10845
10856
  const missing = editing ? formulaMissing ?? (listsChoices ? whatTheChoiceListIsMissing(choiceList) : null) : formulaMissing ?? (listsChoices ? whatTheChoiceListIsMissing(newChoices) : null) ?? (type === "formula" && formulaWritten ? null : whatIsMissing(
10846
- type === "count" ? { type: "rollup", label, options, via, pick, agg: "count", of, relations, formulaFields, relationTarget, allowedTypes, noun } : { type, label, options, via, pick, agg, of, relations: sourcesFor(type), formulaFields, relationTarget, allowedTypes, noun }
10857
+ type === "count" ? { type: "rollup", label, options, via, pick, agg: "count", of, relations: totalSources, formulaFields, relationTarget, allowedTypes, noun } : { type, label, options, via, pick, agg, of, relations: sourcesFor(type), formulaFields, relationTarget, allowedTypes, noun }
10847
10858
  ));
10848
10859
  const save = async () => {
10849
10860
  if (missing) return;
@@ -11337,7 +11348,8 @@ function FieldEditor(props) {
11337
11348
  field2 ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: "ml-auto flex items-center gap-2", children: askingToRemove ? /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
11338
11349
  /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("span", { className: "text-destructive", children: [
11339
11350
  archiveConfirmSentence(`the field \u201C${fieldName(field2)}\u201D`),
11340
- " Its values stay in every record and come back with it."
11351
+ " Its values stay in every record and come back with it.",
11352
+ linkReaders.length > 0 ? ` ${readersSentence(linkReaders.length, farTable.data?.name ?? null)}` : ""
11341
11353
  ] }),
11342
11354
  /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_design_system34.Button, { size: "sm", variant: "destructive", disabled: mutation.saving, onClick: () => void remove(), children: "Remove it" }),
11343
11355
  /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_design_system34.Button, { size: "sm", variant: "ghost", onClick: () => setAskingToRemove(false), children: "Keep it" })
@@ -11597,6 +11609,13 @@ function backLinkAsSource(column) {
11597
11609
  function isBackLinkSource(field2) {
11598
11610
  return field2[BACK_LINK] !== void 0;
11599
11611
  }
11612
+ function readingThroughLink(link, farFields) {
11613
+ const key = link.inverse_key ?? `linked_${link.id}`;
11614
+ return farFields.filter((f) => {
11615
+ const kind = editorKindFor(f);
11616
+ return (kind === "rollup" || kind === "lookup") && f.config?.["via"] === key;
11617
+ });
11618
+ }
11600
11619
  function rollupFilterLead(agg) {
11601
11620
  return agg === "count" ? "Only count records where" : "Only use records where";
11602
11621
  }
@@ -13077,8 +13096,7 @@ function readersThrough(fields, key) {
13077
13096
  function backLinkSentence(column, readers = [], tableName2 = null) {
13078
13097
  const base = `It goes when ${column.source_field_label} is archived on ${column.source_table_name}. Archiving it removes the links it holds there too; it can be brought back from Archived.`;
13079
13098
  if (readers.length === 0) return base;
13080
- const rollups = readers.length === 1 ? "1 rollup" : `${readers.length} rollups`;
13081
- return `${rollups} on ${tableName2 ?? "this table"} read through this. ${base}`;
13099
+ return `${readersSentence(readers.length, tableName2)} ${base}`;
13082
13100
  }
13083
13101
 
13084
13102
  // src/Grid.tsx