@ai-matrx/records-ui 0.116.101 → 0.116.102

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
@@ -9294,6 +9294,25 @@ import { humanizeIdentifier as humanizeIdentifier6 } from "@ai-matrx/kit/text-ca
9294
9294
  import { useState as useState28 } from "react";
9295
9295
  import { Badge as Badge3, Button as Button24, Separator as Separator2 } from "@ai-matrx/design-system";
9296
9296
  import { Fragment as Fragment7, jsx as jsx29, jsxs as jsxs27 } from "react/jsx-runtime";
9297
+ function keptWhileAway(outcome, readBackUnsent, readBackRefusal) {
9298
+ if (!readBackUnsent || outcome.written === 0) return outcome;
9299
+ const values = outcome.readBack + outcome.missing;
9300
+ return {
9301
+ ...outcome,
9302
+ readBack: 0,
9303
+ missing: 0,
9304
+ waiting: values,
9305
+ refusals: readBackRefusal === void 0 ? outcome.refusals : outcome.refusals.filter((why) => why !== readBackRefusal)
9306
+ };
9307
+ }
9308
+ function outcomeSentence(outcome) {
9309
+ const waiting = outcome.waiting ?? 0;
9310
+ if (waiting > 0) {
9311
+ return `${waiting} ${waiting === 1 ? "value is" : "values are"} saved on this computer and will be sent to the table when you are back online.`;
9312
+ }
9313
+ const whole = outcome.missing === 0 && outcome.refusals.length === 0;
9314
+ 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.`;
9315
+ }
9297
9316
  function PastePreview({
9298
9317
  plan,
9299
9318
  noun,
@@ -9436,8 +9455,9 @@ function PastePreview({
9436
9455
  }
9437
9456
  function Outcome({ outcome, onClose }) {
9438
9457
  const whole = outcome.missing === 0 && outcome.refusals.length === 0;
9458
+ const look = (outcome.waiting ?? 0) > 0 ? "waiting" : whole ? "whole" : "partial";
9439
9459
  return /* @__PURE__ */ jsxs27(Fragment7, { children: [
9440
- /* @__PURE__ */ jsx29("p", { className: "text-sm", "data-matrx-paste-outcome": whole ? "whole" : "partial", children: 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.` }),
9460
+ /* @__PURE__ */ jsx29("p", { className: "text-sm", "data-matrx-paste-outcome": look, children: outcomeSentence(outcome) }),
9441
9461
  outcome.refusals.length > 0 ? /* @__PURE__ */ jsx29("ul", { className: "flex flex-col gap-1", children: outcome.refusals.slice(0, 8).map((why, index) => /* @__PURE__ */ jsx29("li", { className: "text-xs text-muted-foreground", children: why }, index)) }) : null,
9442
9462
  /* @__PURE__ */ jsx29("div", { className: "flex justify-end pt-1", children: /* @__PURE__ */ jsx29(Button24, { size: "sm", onClick: onClose, autoFocus: true, children: "Close" }) })
9443
9463
  ] });
@@ -12758,7 +12778,8 @@ function GridBody({
12758
12778
  let missing = 0;
12759
12779
  const fieldOf = new Map((fields.data ?? []).map((f) => [f.key, f]));
12760
12780
  const refusals = [];
12761
- if (!reread.ok) refusals.push(`The rows were written and this could not read them back to check: ${refusalSentence(reread.error)}`);
12781
+ const readBackRefusal = reread.ok ? void 0 : `The rows were written and this could not read them back to check: ${refusalSentence(reread.error)}`;
12782
+ if (readBackRefusal !== void 0) refusals.push(readBackRefusal);
12762
12783
  const seen = new Map((reread.ok ? reread.data : []).map((r) => [r.id, r.document ?? {}]));
12763
12784
  for (const entry of expected) {
12764
12785
  const stored = seen.get(entry.recordId);
@@ -12768,7 +12789,7 @@ function GridBody({
12768
12789
  }
12769
12790
  }
12770
12791
  records.reload();
12771
- return { written: lines2, readBack, missing, refusals };
12792
+ return keptWhileAway({ written: lines2, readBack, missing, refusals }, !reread.ok && isUnsentWrite(reread.error), readBackRefusal);
12772
12793
  },
12773
12794
  [rows, client, tableId, editing, undo, records, versions, fields.data]
12774
12795
  );
@@ -12800,7 +12821,7 @@ function GridBody({
12800
12821
  if (!held) return { written: 0, readBack: 0, missing: 0, refusals: [] };
12801
12822
  if (merged) {
12802
12823
  const outcome = await applyPasteAsOne(held.plan);
12803
- if (outcome.missing === 0 && outcome.refusals.length === 0) {
12824
+ if (outcome.missing === 0 && outcome.refusals.length === 0 && (outcome.waiting ?? 0) === 0) {
12804
12825
  setPastePlan(null);
12805
12826
  sheetController.current?.focusGrid();
12806
12827
  }
@@ -12848,12 +12869,14 @@ function GridBody({
12848
12869
  const fieldOf = new Map((fields.data ?? []).map((f) => [f.key, f]));
12849
12870
  const seen = /* @__PURE__ */ new Map();
12850
12871
  const READ_BACK_PAGE = 500;
12872
+ let readBackRefusal;
12873
+ let readBackUnsent = false;
12851
12874
  for (let offset = 0; ; offset += READ_BACK_PAGE) {
12852
12875
  const reread = await client.list({ table_id: tableId, limit: READ_BACK_PAGE, offset });
12853
12876
  if (!reread.ok) {
12854
- refusals.push(
12855
- `The rows were written and this could not read them back to check: ${refusalSentence(reread.error)}`
12856
- );
12877
+ readBackRefusal = `The rows were written and this could not read them back to check: ${refusalSentence(reread.error)}`;
12878
+ readBackUnsent = isUnsentWrite(reread.error);
12879
+ refusals.push(readBackRefusal);
12857
12880
  break;
12858
12881
  }
12859
12882
  for (const row of reread.data.rows) {
@@ -12873,7 +12896,7 @@ function GridBody({
12873
12896
  }
12874
12897
  }
12875
12898
  records.reload();
12876
- return { written, readBack, missing, refusals };
12899
+ return keptWhileAway({ written, readBack, missing, refusals }, readBackUnsent, readBackRefusal);
12877
12900
  }, [pastePlan, client, tableId, records, merged, applyPasteAsOne, versions, fields.data]);
12878
12901
  const columnIds = useMemo27(() => ordered.map((field) => field.key), [ordered]);
12879
12902
  const lookWrites = useRef19(null);