@ai-matrx/records-ui 0.116.100 → 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.cjs CHANGED
@@ -6845,12 +6845,11 @@ function toStripAndRows(actions, rowCount = STRIP_FEATURE_ROWS) {
6845
6845
  const features = actions.map((a, index) => ({ a, index })).filter(({ a }) => a.verb === void 0).sort((x, y) => (x.a.rank ?? Infinity) - (y.a.rank ?? Infinity) || x.index - y.index).map(({ a }) => a);
6846
6846
  return { strip, rows: features.slice(0, rowCount), more: features.slice(rowCount) };
6847
6847
  }
6848
- var import_tap_target, STANDARD_VERBS, OBJECT_ACTION_GROUPS, GROUP_IDS, DEFAULT_ACTION_ORIGIN, ACTION_NOT_HERE_REASON, ACTION_CHECKING_ACCESS_REASON, ACTION_NO_ACCESS_REASON, ACTION_PLATFORM_TABLE_REASON, BUILT_ON, NOOP, TABLE_ACTION_CHORDS, TABLE_ACTION_KEYS, STRIP_FEATURE_ROWS;
6848
+ var import_tap_shortcut, STANDARD_VERBS, OBJECT_ACTION_GROUPS, GROUP_IDS, DEFAULT_ACTION_ORIGIN, ACTION_NOT_HERE_REASON, ACTION_CHECKING_ACCESS_REASON, ACTION_NO_ACCESS_REASON, ACTION_PLATFORM_TABLE_REASON, BUILT_ON, NOOP, TABLE_ACTION_CHORDS, TABLE_ACTION_KEYS, STRIP_FEATURE_ROWS;
6849
6849
  var init_objectActions = __esm({
6850
6850
  "src/objectActions.ts"() {
6851
6851
  "use strict";
6852
- "use client";
6853
- import_tap_target = require("@ai-matrx/design-system/tap-target");
6852
+ import_tap_shortcut = require("@ai-matrx/design-system/tap-shortcut");
6854
6853
  init_fieldTypes();
6855
6854
  init_rights();
6856
6855
  STANDARD_VERBS = [
@@ -6908,7 +6907,7 @@ var init_objectActions = __esm({
6908
6907
  archive: { code: "Backspace", chord: "alt+shift+backspace" }
6909
6908
  };
6910
6909
  TABLE_ACTION_KEYS = Object.fromEntries(
6911
- Object.entries(TABLE_ACTION_CHORDS).map(([id, { code, chord }]) => [id, { code, label: (0, import_tap_target.formatTapShortcut)(chord) }])
6910
+ Object.entries(TABLE_ACTION_CHORDS).map(([id, { code, chord }]) => [id, { code, label: (0, import_tap_shortcut.formatTapShortcut)(chord) }])
6912
6911
  );
6913
6912
  STRIP_FEATURE_ROWS = 4;
6914
6913
  }
@@ -10049,14 +10048,11 @@ function NumberBox({
10049
10048
  function unitOf(format) {
10050
10049
  return format.options?.unit ?? "px";
10051
10050
  }
10051
+ var SPACING_BAR_MAX_PX = 96;
10052
10052
  function MeasureMini({ px, kind: kind2 }) {
10053
10053
  if (kind2 === "spacing") {
10054
- const gap = Math.max(1, Math.min(px, 48));
10055
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { "aria-hidden": true, "data-records-measure-mini": "spacing", className: "inline-flex h-4 shrink-0 items-center", children: [
10056
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "h-4 w-2.5 rounded-sm border border-border bg-muted" }),
10057
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { width: gap } }),
10058
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "h-4 w-2.5 rounded-sm border border-border bg-muted" })
10059
- ] });
10054
+ const length = Math.max(1, Math.min(px, SPACING_BAR_MAX_PX));
10055
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { "aria-hidden": true, "data-records-measure-mini": "spacing", className: "inline-flex h-4 shrink-0 items-center", style: { width: SPACING_BAR_MAX_PX }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { "data-records-measure-bar": "", className: "h-2 rounded-sm bg-primary", style: { width: length } }) });
10060
10056
  }
10061
10057
  if (kind2 === "border") {
10062
10058
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { "aria-hidden": true, "data-records-measure-mini": "border", className: "inline-block h-5 w-5 shrink-0 rounded-sm bg-card", style: { boxShadow: `inset 0 0 0 ${Math.max(0.5, Math.min(px, 6))}px hsl(var(--foreground))` } });
@@ -18310,7 +18306,7 @@ function AlsoPointsAt({ own: own3, value, onChange }) {
18310
18306
  const toggle = (id, on) => onChange(on ? [...value.filter((v) => v !== id), id] : value.filter((v) => v !== id));
18311
18307
  return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)("div", { className: "flex flex-col gap-1", "data-records-link-also-points-at": "", children: [
18312
18308
  /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_design_system51.Label, { className: "text-xs", children: "Also points at" }),
18313
- tables.loading && entries.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("p", { className: "text-xs text-muted-foreground", children: "Reading tables\u2026" }) : entries.length === 0 && unseen.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("p", { className: "text-xs text-muted-foreground", children: "No other tables yet." }) : /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)("div", { className: "flex max-h-40 flex-col gap-1 overflow-y-auto", children: [
18309
+ tables.loading && entries.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("p", { className: "h-40 text-xs text-muted-foreground", "data-records-also-box": "", children: "Reading tables\u2026" }) : entries.length === 0 && unseen.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("p", { className: "h-40 text-xs text-muted-foreground", "data-records-also-box": "", children: "No other tables yet." }) : /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)("div", { className: "flex h-40 flex-col gap-1 overflow-y-auto", "data-records-also-box": "", children: [
18314
18310
  entries.map((e) => /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)("label", { className: "flex items-center gap-1.5 text-sm", children: [
18315
18311
  /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
18316
18312
  import_design_system51.Checkbox,
@@ -25517,7 +25513,7 @@ var import_react198 = require("@ai-matrx/records/react");
25517
25513
  var import_records51 = require("@ai-matrx/records");
25518
25514
  var import_records52 = require("@ai-matrx/records");
25519
25515
  var import_data_table14 = require("@ai-matrx/design-system/data-table");
25520
- var import_core20 = require("@ai-matrx/records/core");
25516
+ var import_core21 = require("@ai-matrx/records/core");
25521
25517
 
25522
25518
  // src/tableDecorations.ts
25523
25519
  var import_react117 = require("react");
@@ -25689,7 +25685,7 @@ function useTableCanBeCleaned(tableId) {
25689
25685
 
25690
25686
  // src/gridControls.tsx
25691
25687
  var import_clipboard3 = require("@ai-matrx/kit/clipboard");
25692
- var import_core16 = require("@ai-matrx/records/core");
25688
+ var import_core17 = require("@ai-matrx/records/core");
25693
25689
  var import_react158 = require("react");
25694
25690
  var import_react159 = require("@ai-matrx/records/react");
25695
25691
  var import_design_system86 = require("@ai-matrx/design-system");
@@ -25710,6 +25706,7 @@ var import_react122 = require("@ai-matrx/records/react");
25710
25706
  var import_records42 = require("@ai-matrx/records");
25711
25707
  var import_design_system68 = require("@ai-matrx/design-system");
25712
25708
  var import_format8 = require("@ai-matrx/kit/format");
25709
+ var import_core15 = require("@ai-matrx/records/core");
25713
25710
  init_Refusal();
25714
25711
  init_refusals();
25715
25712
  init_host();
@@ -25901,17 +25898,29 @@ function useEnrichCells(tableId, recordIds) {
25901
25898
  return { cells, refresh, error };
25902
25899
  }
25903
25900
  var NEVER2 = "Fill it in once and leave it alone";
25904
- var FILL_TRY_MAX = 10;
25905
- var FILL_ROWS_MAX = 50;
25906
- var FILL_N_DEFAULT = "3";
25907
- function dueRowsEstimate(row) {
25901
+ function useFillLimits(client) {
25902
+ const [limits, setLimits] = (0, import_react121.useState)(null);
25903
+ (0, import_react121.useEffect)(() => {
25904
+ let live = true;
25905
+ if (!client?.recordsLimits) {
25906
+ setLimits({ ...import_core15.RECORDS_LIMITS_DEFAULTS });
25907
+ return;
25908
+ }
25909
+ void client.recordsLimits().then((got) => live && setLimits(got), () => live && setLimits({ ...import_core15.RECORDS_LIMITS_DEFAULTS }));
25910
+ return () => {
25911
+ live = false;
25912
+ };
25913
+ }, [client]);
25914
+ return limits;
25915
+ }
25916
+ function dueRowsEstimate(row, rowsMax = import_core15.RECORDS_LIMITS_DEFAULTS.aiFillRowsMax) {
25908
25917
  const empty = Math.max(0, Number(row.rows_total) - Number(row.rows_filled));
25909
- return Math.max(1, Math.min(FILL_ROWS_MAX, empty));
25918
+ return Math.max(1, Math.min(rowsMax, empty));
25910
25919
  }
25911
- function fillCountFrom(text) {
25920
+ function fillCountFrom(text, rowsMax = import_core15.RECORDS_LIMITS_DEFAULTS.aiFillRowsMax) {
25912
25921
  if (!/^\d+$/.test(text.trim())) return null;
25913
25922
  const n = Number(text);
25914
- return n >= 1 && n <= FILL_ROWS_MAX ? n : null;
25923
+ return n >= 1 && n <= rowsMax ? n : null;
25915
25924
  }
25916
25925
  function EnrichPanel({ tableId, fieldId, className }) {
25917
25926
  const client = (0, import_react122.useRecordsClient)();
@@ -25920,6 +25929,10 @@ function EnrichPanel({ tableId, fieldId, className }) {
25920
25929
  const table = (0, import_react122.useTable)(tableId);
25921
25930
  const fields = (0, import_react122.useFields)(tableId);
25922
25931
  const rights = useTableRights(table.data);
25932
+ const limits = useFillLimits(client);
25933
+ const tryMax = limits?.aiFillTryMax ?? 0;
25934
+ const rowsMax = limits?.aiFillRowsMax ?? 0;
25935
+ const startN = String(limits?.aiFillDefaultRows ?? "");
25923
25936
  const [rows, setRows] = (0, import_react121.useState)(null);
25924
25937
  const [error, setError] = (0, import_react121.useState)(null);
25925
25938
  const [busy, setBusy] = (0, import_react121.useState)(null);
@@ -25990,7 +26003,7 @@ function EnrichPanel({ tableId, fieldId, className }) {
25990
26003
  tableId,
25991
26004
  fieldId: row.field_id,
25992
26005
  fieldKey: row.field_key,
25993
- rows: count ?? (previewOnly ? 5 : 50),
26006
+ rows: count ?? (previewOnly ? 5 : rowsMax),
25994
26007
  previewOnly
25995
26008
  });
25996
26009
  setBusy(null);
@@ -26001,11 +26014,11 @@ function EnrichPanel({ tableId, fieldId, className }) {
26001
26014
  }
26002
26015
  if (!previewOnly) await load();
26003
26016
  },
26004
- [host, load, tableId]
26017
+ [host, load, tableId, rowsMax]
26005
26018
  );
26006
26019
  const startFill = (0, import_react121.useCallback)(
26007
26020
  (row, count) => {
26008
- if (count > FILL_TRY_MAX) {
26021
+ if (count > tryMax) {
26009
26022
  setConfirming({ fieldId: row.field_id, count });
26010
26023
  if (row.cost_per_row_cents === null && previewCost[row.field_id] === void 0 && host.estimateFill) {
26011
26024
  const key = `${row.field_id}:${count}`;
@@ -26017,7 +26030,7 @@ function EnrichPanel({ tableId, fieldId, className }) {
26017
26030
  setConfirming(null);
26018
26031
  void runIt(row, false, count);
26019
26032
  },
26020
- [runIt, previewCost, host, tableId]
26033
+ [runIt, previewCost, host, tableId, tryMax]
26021
26034
  );
26022
26035
  if (error) return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(RefusalNotice, { error, className });
26023
26036
  if (rows === null) return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_design_system68.Skeleton, { className: (0, import_design_system68.cn)("h-40 w-full", className) });
@@ -26258,7 +26271,7 @@ function EnrichPanel({ tableId, fieldId, className }) {
26258
26271
  children: "Show me five rows it would do"
26259
26272
  }
26260
26273
  ),
26261
- host.enrich ? /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(import_jsx_runtime80.Fragment, { children: [
26274
+ host.enrich && limits === null ? /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_design_system68.Skeleton, { className: "h-8 w-64", "data-enrich-limits-reading": "" }) : host.enrich ? /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(import_jsx_runtime80.Fragment, { children: [
26262
26275
  /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
26263
26276
  import_design_system68.Button,
26264
26277
  {
@@ -26287,10 +26300,10 @@ function EnrichPanel({ tableId, fieldId, className }) {
26287
26300
  type: "number",
26288
26301
  inputMode: "numeric",
26289
26302
  min: 1,
26290
- max: FILL_ROWS_MAX,
26303
+ max: rowsMax,
26291
26304
  className: "h-8 w-16",
26292
26305
  "aria-label": "How many rows to fill",
26293
- value: fillN[row.field_id] ?? FILL_N_DEFAULT,
26306
+ value: fillN[row.field_id] ?? startN,
26294
26307
  onChange: (e) => setFillN((prev) => ({ ...prev, [row.field_id]: e.target.value }))
26295
26308
  }
26296
26309
  ),
@@ -26299,15 +26312,15 @@ function EnrichPanel({ tableId, fieldId, className }) {
26299
26312
  {
26300
26313
  size: "sm",
26301
26314
  variant: "outline",
26302
- disabled: busy === row.field_id || !row.enabled || fillCountFrom(fillN[row.field_id] ?? FILL_N_DEFAULT) === null,
26315
+ disabled: busy === row.field_id || !row.enabled || fillCountFrom(fillN[row.field_id] ?? startN, rowsMax) === null,
26303
26316
  title: row.enabled ? void 0 : FILL_OFF_REASON,
26304
26317
  "data-enrich-fill-rows": "",
26305
26318
  onClick: () => {
26306
- const n = fillCountFrom(fillN[row.field_id] ?? FILL_N_DEFAULT);
26319
+ const n = fillCountFrom(fillN[row.field_id] ?? startN, rowsMax);
26307
26320
  if (n !== null) startFill(row, n);
26308
26321
  },
26309
26322
  children: (() => {
26310
- const n = fillCountFrom(fillN[row.field_id] ?? FILL_N_DEFAULT);
26323
+ const n = fillCountFrom(fillN[row.field_id] ?? startN, rowsMax);
26311
26324
  return n === null ? "Fill rows" : `Fill ${n} ${n === 1 ? "row" : "rows"}`;
26312
26325
  })()
26313
26326
  }
@@ -26320,7 +26333,7 @@ function EnrichPanel({ tableId, fieldId, className }) {
26320
26333
  disabled: busy === row.field_id || !row.enabled,
26321
26334
  title: row.enabled ? void 0 : FILL_OFF_REASON,
26322
26335
  "data-enrich-fill-due": "",
26323
- onClick: () => startFill(row, dueRowsEstimate(row)),
26336
+ onClick: () => startFill(row, dueRowsEstimate(row, rowsMax)),
26324
26337
  children: "Fill in what is due"
26325
26338
  }
26326
26339
  )
@@ -27423,17 +27436,17 @@ function MoveUnderDialog({ tableId, record, document: document2, open, onOpenCha
27423
27436
  disabled: busy
27424
27437
  }
27425
27438
  ),
27426
- parentTableId ? /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
27439
+ /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
27427
27440
  import_design_system73.Input,
27428
27441
  {
27429
27442
  value: search,
27430
27443
  onChange: (e) => setSearch(e.target.value),
27431
- placeholder: `Find in ${parentTableName}`,
27444
+ placeholder: parentTableId ? `Find in ${parentTableName}` : "Pick a table first",
27432
27445
  "aria-label": asHome ? "Find the record it also lives in" : "Find the record to move it under",
27433
- disabled: busy,
27446
+ disabled: busy || !parentTableId,
27434
27447
  "data-records-move-under-search": ""
27435
27448
  }
27436
- ) : null,
27449
+ ),
27437
27450
  /* @__PURE__ */ (0, import_jsx_runtime86.jsx)("div", { className: "h-48 overflow-y-auto", "data-records-move-under-list": "", children: !parentTableId ? null : rows === null ? /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)("div", { className: "flex flex-col gap-2", children: [
27438
27451
  /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(import_design_system73.Skeleton, { className: "h-7 w-full" }),
27439
27452
  /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(import_design_system73.Skeleton, { className: "h-7 w-full" }),
@@ -27586,7 +27599,7 @@ function MoveRecordDialog({ tableId, record, document: document2, open, onOpenCh
27586
27599
  // src/printLayouts.tsx
27587
27600
  var import_react143 = require("react");
27588
27601
  var import_react144 = require("@ai-matrx/records/react");
27589
- var import_core15 = require("@ai-matrx/print/core");
27602
+ var import_core16 = require("@ai-matrx/print/core");
27590
27603
  var import_design_system77 = require("@ai-matrx/design-system");
27591
27604
 
27592
27605
  // src/DocTemplate.tsx
@@ -28075,7 +28088,7 @@ function layoutPagesDocument(layoutName, pages) {
28075
28088
  return `<section class="layout-page layout-page-set" data-layout-page="">${noteHtml}${regionHtml("header", split.settings.header, logo)}<div class="layout-text">${escapeText(split.body)}</div>${regionHtml("footer", split.settings.footer)}</section>`;
28076
28089
  }).join("");
28077
28090
  const pageCss = sheet ? layoutPageCss(sheet) : "";
28078
- return (0, import_core15.buildPrintDocument)(body, layoutName, `${LAYOUT_STYLES}${pageCss}`);
28091
+ return (0, import_core16.buildPrintDocument)(body, layoutName, `${LAYOUT_STYLES}${pageCss}`);
28079
28092
  }
28080
28093
  function PrintWithLayoutDialog({ tableId, recordIds, names: names2, open, onOpenChange }) {
28081
28094
  const client = (0, import_react144.useRecordsClient)();
@@ -28105,7 +28118,7 @@ function PrintWithLayoutDialog({ tableId, recordIds, names: names2, open, onOpen
28105
28118
  if (!layout) return;
28106
28119
  setBusy(true);
28107
28120
  setNote(null);
28108
- const pending = (0, import_core15.openPendingPrintWindow)(layout.name);
28121
+ const pending = (0, import_core16.openPendingPrintWindow)(layout.name);
28109
28122
  const pages = [];
28110
28123
  for (const id of recordIds) {
28111
28124
  const body = await client.docRenderBody({ template_id: layout.id, record_id: id });
@@ -30015,7 +30028,7 @@ function useMergedGridControls(args) {
30015
30028
  const fieldsRef = (0, import_react158.useRef)(fields);
30016
30029
  fieldsRef.current = fields;
30017
30030
  const [choiceCounts, setChoiceCounts] = (0, import_react158.useState)({});
30018
- (0, import_react158.useEffect)(() => (0, import_core16.onRecordChanged)(() => (0, askOnce_exports.forgetAsked)(client, `value_counts:${tableId}:`)), [client, tableId]);
30031
+ (0, import_react158.useEffect)(() => (0, import_core17.onRecordChanged)(() => (0, askOnce_exports.forgetAsked)(client, `value_counts:${tableId}:`)), [client, tableId]);
30019
30032
  (0, import_react158.useEffect)(() => {
30020
30033
  if (!enabled || choiceKeys.length === 0) {
30021
30034
  setChoiceCounts({});
@@ -32411,6 +32424,25 @@ var import_design_system90 = require("@ai-matrx/design-system");
32411
32424
  init_Refusal();
32412
32425
  init_refusals();
32413
32426
  var import_jsx_runtime104 = require("react/jsx-runtime");
32427
+ function keptWhileAway(outcome, readBackUnsent, readBackRefusal) {
32428
+ if (!readBackUnsent || outcome.written === 0) return outcome;
32429
+ const values = outcome.readBack + outcome.missing;
32430
+ return {
32431
+ ...outcome,
32432
+ readBack: 0,
32433
+ missing: 0,
32434
+ waiting: values,
32435
+ refusals: readBackRefusal === void 0 ? outcome.refusals : outcome.refusals.filter((why) => why !== readBackRefusal)
32436
+ };
32437
+ }
32438
+ function outcomeSentence(outcome) {
32439
+ const waiting = outcome.waiting ?? 0;
32440
+ if (waiting > 0) {
32441
+ return `${waiting} ${waiting === 1 ? "value is" : "values are"} saved on this computer and will be sent to the table when you are back online.`;
32442
+ }
32443
+ const whole = outcome.missing === 0 && outcome.refusals.length === 0;
32444
+ 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.`;
32445
+ }
32414
32446
  function PastePreview({
32415
32447
  plan,
32416
32448
  noun,
@@ -32553,8 +32585,9 @@ function PastePreview({
32553
32585
  }
32554
32586
  function Outcome({ outcome, onClose }) {
32555
32587
  const whole = outcome.missing === 0 && outcome.refusals.length === 0;
32588
+ const look = (outcome.waiting ?? 0) > 0 ? "waiting" : whole ? "whole" : "partial";
32556
32589
  return /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)(import_jsx_runtime104.Fragment, { children: [
32557
- /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("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.` }),
32590
+ /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("p", { className: "text-sm", "data-matrx-paste-outcome": look, children: outcomeSentence(outcome) }),
32558
32591
  outcome.refusals.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("ul", { className: "flex flex-col gap-1", children: outcome.refusals.slice(0, 8).map((why, index) => /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("li", { className: "text-xs text-muted-foreground", children: why }, index)) }) : null,
32559
32592
  /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("div", { className: "flex justify-end pt-1", children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(import_design_system90.Button, { size: "sm", onClick: onClose, autoFocus: true, children: "Close" }) })
32560
32593
  ] });
@@ -33739,7 +33772,7 @@ function useGroupLabel(fields, groupKey, thenKeys = []) {
33739
33772
  // src/gridUndo.tsx
33740
33773
  var import_react185 = require("react");
33741
33774
  var import_react186 = require("@ai-matrx/records/react");
33742
- var import_core17 = require("@ai-matrx/records/core");
33775
+ var import_core18 = require("@ai-matrx/records/core");
33743
33776
  var import_design_system98 = require("@ai-matrx/design-system");
33744
33777
  init_plainWords();
33745
33778
  var import_data_table13 = require("@ai-matrx/design-system/data-table");
@@ -33835,7 +33868,7 @@ function useGridUndo(args) {
33835
33868
  }
33836
33869
  forget(step2.cells.map((c) => ({ rowId: c.rowId, key: c.key })));
33837
33870
  for (const id of /* @__PURE__ */ new Set([...step2.cells.map((c) => c.rowId), ...step2.created ?? [], ...step2.archived ?? []])) {
33838
- (0, import_core17.announceRecordChanged)(id);
33871
+ (0, import_core18.announceRecordChanged)(id);
33839
33872
  }
33840
33873
  setHeld(() => {
33841
33874
  let stack = taken.stack;
@@ -34132,7 +34165,7 @@ function useRowFollowsItsMove(args) {
34132
34165
  // src/gridAssist.tsx
34133
34166
  var import_clipboard5 = require("@ai-matrx/kit/clipboard");
34134
34167
  var import_react189 = require("react");
34135
- var import_core18 = require("@ai-matrx/records/core");
34168
+ var import_core19 = require("@ai-matrx/records/core");
34136
34169
  var import_workspace = require("@ai-matrx/alchemy/react/workspace");
34137
34170
 
34138
34171
  // src/gridAgentContext.ts
@@ -34264,7 +34297,7 @@ function useGridAssist(args) {
34264
34297
  const copyRecordReference = (0, import_react189.useCallback)(
34265
34298
  (rowId) => {
34266
34299
  void (async () => {
34267
- const text = JSON.stringify({ __kind: (0, import_core18.tableKindSlug)(tableId), _record_id: rowId });
34300
+ const text = JSON.stringify({ __kind: (0, import_core19.tableKindSlug)(tableId), _record_id: rowId });
34268
34301
  if (!await (0, import_clipboard5.copyText)(text)) {
34269
34302
  say2(false, "This browser did not let the page write to the clipboard.");
34270
34303
  return;
@@ -34320,7 +34353,7 @@ function useGridAssist(args) {
34320
34353
  if (!row) return;
34321
34354
  const document2 = row.document ?? {};
34322
34355
  const value = editing.valueFor(row, fieldOf2(key));
34323
- const pointer = typeof document2[key] === "string" ? (0, import_core18.wholeValueOf)(document2, key) : null;
34356
+ const pointer = typeof document2[key] === "string" ? (0, import_core19.wholeValueOf)(document2, key) : null;
34324
34357
  setWhole({ rowId, key, rowTitle: titleOf(row), value, pointer });
34325
34358
  },
34326
34359
  [rowOf, fieldOf2, titleOf, editing]
@@ -34416,7 +34449,7 @@ function useGridAssist(args) {
34416
34449
  // src/gridBulk.tsx
34417
34450
  var import_react190 = require("react");
34418
34451
  var import_react191 = require("@ai-matrx/records/react");
34419
- var import_core19 = require("@ai-matrx/records/core");
34452
+ var import_core20 = require("@ai-matrx/records/core");
34420
34453
  init_recordVersions();
34421
34454
  var import_design_system99 = require("@ai-matrx/design-system");
34422
34455
  init_names();
@@ -34485,7 +34518,7 @@ function useGridBulk(args) {
34485
34518
  return null;
34486
34519
  }
34487
34520
  for (const result of done.data ?? []) if (result.op === "update") versions.wrote(result.id, result.version);
34488
- for (const change of changes) if ("record_id" in change && change.record_id) (0, import_core19.announceRecordChanged)(change.record_id);
34521
+ for (const change of changes) if ("record_id" in change && change.record_id) (0, import_core20.announceRecordChanged)(change.record_id);
34489
34522
  return done.data;
34490
34523
  },
34491
34524
  [client, tableId, versions, reload]
@@ -35842,7 +35875,7 @@ function GridBody({
35842
35875
  }))
35843
35876
  );
35844
35877
  editing.forget(cells);
35845
- for (const u of updates) (0, import_core20.announceRecordChanged)(u.row.recordId);
35878
+ for (const u of updates) (0, import_core21.announceRecordChanged)(u.row.recordId);
35846
35879
  const lines2 = updates.length + creates.length;
35847
35880
  undo.push({ label: `Pasted ${lines2} ${lines2 === 1 ? "row" : "rows"}`, cells, created });
35848
35881
  const expected = [
@@ -35854,7 +35887,8 @@ function GridBody({
35854
35887
  let missing = 0;
35855
35888
  const fieldOf2 = new Map((fields.data ?? []).map((f) => [f.key, f]));
35856
35889
  const refusals = [];
35857
- if (!reread.ok) refusals.push(`The rows were written and this could not read them back to check: ${refusalSentence(reread.error)}`);
35890
+ const readBackRefusal = reread.ok ? void 0 : `The rows were written and this could not read them back to check: ${refusalSentence(reread.error)}`;
35891
+ if (readBackRefusal !== void 0) refusals.push(readBackRefusal);
35858
35892
  const seen = new Map((reread.ok ? reread.data : []).map((r) => [r.id, r.document ?? {}]));
35859
35893
  for (const entry of expected) {
35860
35894
  const stored = seen.get(entry.recordId);
@@ -35864,7 +35898,7 @@ function GridBody({
35864
35898
  }
35865
35899
  }
35866
35900
  records.reload();
35867
- return { written: lines2, readBack, missing, refusals };
35901
+ return keptWhileAway({ written: lines2, readBack, missing, refusals }, !reread.ok && isUnsentWrite(reread.error), readBackRefusal);
35868
35902
  },
35869
35903
  [rows, client, tableId, editing, undo, records, versions, fields.data]
35870
35904
  );
@@ -35896,7 +35930,7 @@ function GridBody({
35896
35930
  if (!held) return { written: 0, readBack: 0, missing: 0, refusals: [] };
35897
35931
  if (merged) {
35898
35932
  const outcome = await applyPasteAsOne(held.plan);
35899
- if (outcome.missing === 0 && outcome.refusals.length === 0) {
35933
+ if (outcome.missing === 0 && outcome.refusals.length === 0 && (outcome.waiting ?? 0) === 0) {
35900
35934
  setPastePlan(null);
35901
35935
  sheetController.current?.focusGrid();
35902
35936
  }
@@ -35944,12 +35978,14 @@ function GridBody({
35944
35978
  const fieldOf2 = new Map((fields.data ?? []).map((f) => [f.key, f]));
35945
35979
  const seen = /* @__PURE__ */ new Map();
35946
35980
  const READ_BACK_PAGE = 500;
35981
+ let readBackRefusal;
35982
+ let readBackUnsent = false;
35947
35983
  for (let offset = 0; ; offset += READ_BACK_PAGE) {
35948
35984
  const reread = await client.list({ table_id: tableId, limit: READ_BACK_PAGE, offset });
35949
35985
  if (!reread.ok) {
35950
- refusals.push(
35951
- `The rows were written and this could not read them back to check: ${refusalSentence(reread.error)}`
35952
- );
35986
+ readBackRefusal = `The rows were written and this could not read them back to check: ${refusalSentence(reread.error)}`;
35987
+ readBackUnsent = isUnsentWrite(reread.error);
35988
+ refusals.push(readBackRefusal);
35953
35989
  break;
35954
35990
  }
35955
35991
  for (const row of reread.data.rows) {
@@ -35969,7 +36005,7 @@ function GridBody({
35969
36005
  }
35970
36006
  }
35971
36007
  records.reload();
35972
- return { written, readBack, missing, refusals };
36008
+ return keptWhileAway({ written, readBack, missing, refusals }, readBackUnsent, readBackRefusal);
35973
36009
  }, [pastePlan, client, tableId, records, merged, applyPasteAsOne, versions, fields.data]);
35974
36010
  const columnIds = (0, import_react197.useMemo)(() => ordered.map((field2) => field2.key), [ordered]);
35975
36011
  const lookWrites = (0, import_react197.useRef)(null);
@@ -36147,7 +36183,7 @@ function GridBody({
36147
36183
  const values = presetValues ? withNewRowValues(presetValues, given) : given;
36148
36184
  setAddRefused(null);
36149
36185
  if (formHosted && fields.data) {
36150
- const wouldRefuse = (0, import_core20.predictWriteRefusals)({ fields: fields.data, document: values ?? {} });
36186
+ const wouldRefuse = (0, import_core21.predictWriteRefusals)({ fields: fields.data, document: values ?? {} });
36151
36187
  if (wouldRefuse.length > 0) {
36152
36188
  setFormAsk((held) => ({ n: (held?.n ?? 0) + 1, initial: { ...values ?? {} } }));
36153
36189
  return;
@@ -41007,7 +41043,7 @@ var import_clipboard7 = require("@ai-matrx/kit/clipboard");
41007
41043
  var import_download2 = require("@ai-matrx/kit/download");
41008
41044
  var import_react236 = require("react");
41009
41045
  var import_react237 = require("@ai-matrx/records/react");
41010
- var import_core21 = require("@ai-matrx/records/core");
41046
+ var import_core22 = require("@ai-matrx/records/core");
41011
41047
  init_host();
41012
41048
 
41013
41049
  // src/viewExport.ts
@@ -41092,7 +41128,7 @@ async function rowsForFile(args) {
41092
41128
  );
41093
41129
  const lookup = ((field2, id) => labels(field2, id) ?? learned.get(`${field2.id}:${id}`) ?? null);
41094
41130
  const read = host.readFileText;
41095
- return (0, import_core21.withWholeValues)(toRows(all, records, lookup), read ? (fileId) => read({ fileId }) : null);
41131
+ return (0, import_core22.withWholeValues)(toRows(all, records, lookup), read ? (fileId) => read({ fileId }) : null);
41096
41132
  }
41097
41133
  function ExportMenu({ tableId, rows, label, className, view }) {
41098
41134
  const client = (0, import_react237.useRecordsClient)();
@@ -46917,7 +46953,7 @@ var import_controls17 = require("@ai-matrx/design-system/controls");
46917
46953
  var import_react289 = require("react");
46918
46954
  var import_recharts = require("recharts");
46919
46955
  var import_records61 = require("@ai-matrx/records");
46920
- var import_core22 = require("@ai-matrx/records/core");
46956
+ var import_core23 = require("@ai-matrx/records/core");
46921
46957
  var import_design_system140 = require("@ai-matrx/design-system");
46922
46958
  var import_format13 = require("@ai-matrx/kit/format");
46923
46959
  init_Refusal();
@@ -47478,7 +47514,7 @@ function prettyPlain(n) {
47478
47514
  return Number.isInteger(n) ? n.toLocaleString() : n.toLocaleString(void 0, { maximumFractionDigits: 2 });
47479
47515
  }
47480
47516
  function asRefusal2(block) {
47481
- return (0, import_core22.mapPgError)(
47517
+ return (0, import_core23.mapPgError)(
47482
47518
  {
47483
47519
  message: block.refused ?? "",
47484
47520
  ...block.sqlstate ? { code: block.sqlstate } : {}
@@ -51005,7 +51041,7 @@ var import_react305 = require("react");
51005
51041
  var import_react306 = require("@ai-matrx/records/react");
51006
51042
  var import_design_system149 = require("@ai-matrx/design-system");
51007
51043
  var import_controls21 = require("@ai-matrx/design-system/controls");
51008
- var import_core23 = require("@dnd-kit/core");
51044
+ var import_core24 = require("@dnd-kit/core");
51009
51045
  var import_sortable = require("@dnd-kit/sortable");
51010
51046
  var import_utilities = require("@dnd-kit/utilities");
51011
51047
  init_Refusal();
@@ -51087,7 +51123,7 @@ function seedIsSatisfied(seed, views) {
51087
51123
  return seed.isDefault === true && views.some((v) => v.isDefault);
51088
51124
  }
51089
51125
  function SectionBox({ id, children, ...rest }) {
51090
- const { setNodeRef, isOver } = (0, import_core23.useDroppable)({ id });
51126
+ const { setNodeRef, isOver } = (0, import_core24.useDroppable)({ id });
51091
51127
  return /* @__PURE__ */ (0, import_jsx_runtime174.jsx)("div", { ref: setNodeRef, className: (0, import_design_system149.cn)("rounded-sm", isOver && "bg-accent/40"), ...rest, children });
51092
51128
  }
51093
51129
  function SortableRow({ id, disabled, children }) {
@@ -51142,7 +51178,7 @@ function ViewBar({ tableId, activeViewId, onActiveView, seed, settings, onViews,
51142
51178
  const [renamingSection, setRenamingSection] = (0, import_react305.useState)(null);
51143
51179
  const [dragging, setDragging] = (0, import_react305.useState)(false);
51144
51180
  const justDragged = (0, import_react305.useRef)(false);
51145
- const sensors = (0, import_core23.useSensors)((0, import_core23.useSensor)(import_core23.PointerSensor, { activationConstraint: { distance: 6 } }));
51181
+ const sensors = (0, import_core24.useSensors)((0, import_core24.useSensor)(import_core24.PointerSensor, { activationConstraint: { distance: 6 } }));
51146
51182
  async function dropped(event) {
51147
51183
  setDragging(false);
51148
51184
  justDragged.current = true;
@@ -51397,7 +51433,7 @@ function ViewBar({ tableId, activeViewId, onActiveView, seed, settings, onViews,
51397
51433
  ) }),
51398
51434
  /* @__PURE__ */ (0, import_jsx_runtime174.jsxs)(import_design_system149.PopoverContent, { sizing: "content", align: "start", className: "w-64 p-1", "data-view-picker-content": "", children: [
51399
51435
  /* @__PURE__ */ (0, import_jsx_runtime174.jsxs)("div", { role: "group", "aria-label": "Saved views", className: "flex max-h-[50dvh] flex-col overflow-y-auto", children: [
51400
- /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(import_core23.DndContext, { sensors, collisionDetection: import_core23.closestCenter, onDragStart: () => setDragging(true), onDragCancel: () => setDragging(false), onDragEnd: (e) => void dropped(e), children: (() => {
51436
+ /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(import_core24.DndContext, { sensors, collisionDetection: import_core24.closestCenter, onDragStart: () => setDragging(true), onDragCancel: () => setDragging(false), onDragEnd: (e) => void dropped(e), children: (() => {
51401
51437
  const groups = (0, import_views2.groupViewsBySection)(views);
51402
51438
  return groups.some((g) => g.name === null) || !dragging ? groups : [{ name: null, views: [] }, ...groups];
51403
51439
  })().map((group) => /* @__PURE__ */ (0, import_jsx_runtime174.jsxs)(SectionBox, { id: (0, import_views2.sectionDropId)(group.name), role: "group", "aria-label": group.name ?? "Views", "data-view-section": group.name ?? "", children: [
@@ -55047,7 +55083,7 @@ var import_drafts = require("@ai-matrx/kit/drafts");
55047
55083
  var import_design_system164 = require("@ai-matrx/design-system");
55048
55084
  var import_controls25 = require("@ai-matrx/design-system/controls");
55049
55085
  var import_react331 = require("react");
55050
- var import_core24 = require("@dnd-kit/core");
55086
+ var import_core25 = require("@dnd-kit/core");
55051
55087
  var import_sortable2 = require("@dnd-kit/sortable");
55052
55088
  var import_utilities2 = require("@dnd-kit/utilities");
55053
55089
  var import_react332 = require("@ai-matrx/records/react");
@@ -57000,9 +57036,9 @@ function QuestionList({
57000
57036
  onQuestions,
57001
57037
  onQuestion
57002
57038
  }) {
57003
- const sensors = (0, import_core24.useSensors)(
57004
- (0, import_core24.useSensor)(import_core24.PointerSensor, { activationConstraint: { distance: 4 } }),
57005
- (0, import_core24.useSensor)(import_core24.KeyboardSensor, { coordinateGetter: import_sortable2.sortableKeyboardCoordinates })
57039
+ const sensors = (0, import_core25.useSensors)(
57040
+ (0, import_core25.useSensor)(import_core25.PointerSensor, { activationConstraint: { distance: 4 } }),
57041
+ (0, import_core25.useSensor)(import_core25.KeyboardSensor, { coordinateGetter: import_sortable2.sortableKeyboardCoordinates })
57006
57042
  );
57007
57043
  const askable = askableFields([...fields]);
57008
57044
  const unasked = askable.filter((f) => !draft.questions.some((q) => q.field === f.key));
@@ -57024,7 +57060,7 @@ function QuestionList({
57024
57060
  /* @__PURE__ */ (0, import_jsx_runtime189.jsx)("span", { className: "font-medium text-foreground", children: "Questions" }),
57025
57061
  /* @__PURE__ */ (0, import_jsx_runtime189.jsx)("span", { className: "tabular-nums", children: draft.questions.length })
57026
57062
  ] }),
57027
- /* @__PURE__ */ (0, import_jsx_runtime189.jsx)(import_core24.DndContext, { sensors, collisionDetection: import_core24.closestCenter, onDragEnd: dragEnd, children: /* @__PURE__ */ (0, import_jsx_runtime189.jsx)(import_sortable2.SortableContext, { items: draft.questions.map((q) => q.field), strategy: import_sortable2.verticalListSortingStrategy, children: draft.questions.map((question, index) => /* @__PURE__ */ (0, import_jsx_runtime189.jsx)(
57063
+ /* @__PURE__ */ (0, import_jsx_runtime189.jsx)(import_core25.DndContext, { sensors, collisionDetection: import_core25.closestCenter, onDragEnd: dragEnd, children: /* @__PURE__ */ (0, import_jsx_runtime189.jsx)(import_sortable2.SortableContext, { items: draft.questions.map((q) => q.field), strategy: import_sortable2.verticalListSortingStrategy, children: draft.questions.map((question, index) => /* @__PURE__ */ (0, import_jsx_runtime189.jsx)(
57028
57064
  QuestionRow,
57029
57065
  {
57030
57066
  index,
@@ -60068,7 +60104,7 @@ init_host();
60068
60104
  // src/PageCanvas.tsx
60069
60105
  var import_react348 = require("react");
60070
60106
  var import_react349 = require("@ai-matrx/records/react");
60071
- var import_core25 = require("@ai-matrx/records/core");
60107
+ var import_core26 = require("@ai-matrx/records/core");
60072
60108
  var import_download3 = require("@ai-matrx/kit/download");
60073
60109
  var import_format17 = require("@ai-matrx/kit/format");
60074
60110
  var import_design_system174 = require("@ai-matrx/design-system");
@@ -60308,7 +60344,7 @@ function useMemberRows(block, viewerUserId, extra, mineOn, enabled) {
60308
60344
  ...q.sort.length > 0 ? { sort: q.sort } : {}
60309
60345
  });
60310
60346
  const reload = page.reload;
60311
- (0, import_react348.useEffect)(() => (0, import_core25.onRecordChanged)(() => reload()), [reload]);
60347
+ (0, import_react348.useEffect)(() => (0, import_core26.onRecordChanged)(() => reload()), [reload]);
60312
60348
  return { q, page };
60313
60349
  }
60314
60350
  function BlockBody(inner2) {
@@ -61240,7 +61276,7 @@ function onePerKey3(all) {
61240
61276
  }
61241
61277
 
61242
61278
  // src/printPage.ts
61243
- var import_core26 = require("@ai-matrx/print/core");
61279
+ var import_core27 = require("@ai-matrx/print/core");
61244
61280
  var PAGE_PRINT_STYLES = `
61245
61281
  .page-print-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 12px; }
61246
61282
  .page-print-grid > * { grid-column: span 12; break-inside: avoid; }
@@ -61251,7 +61287,7 @@ function printRecordsPage(element, title) {
61251
61287
  const copy = element.cloneNode(true);
61252
61288
  copy.querySelectorAll("button, input, select, textarea, iframe, [data-records-page-settings], [data-records-page-csv]").forEach((n) => n.remove());
61253
61289
  copy.classList.add("page-print-grid");
61254
- return (0, import_core26.openPrintWindow)((0, import_core26.buildPrintDocument)(`<h1>${escapeText2(title)}</h1>${copy.innerHTML}`, title, PAGE_PRINT_STYLES), title);
61290
+ return (0, import_core27.openPrintWindow)((0, import_core27.buildPrintDocument)(`<h1>${escapeText2(title)}</h1>${copy.innerHTML}`, title, PAGE_PRINT_STYLES), title);
61255
61291
  }
61256
61292
  function escapeText2(text) {
61257
61293
  return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
@@ -63118,7 +63154,7 @@ function CalendarSubscribeDialog({
63118
63154
 
63119
63155
  // src/viewShare.ts
63120
63156
  var import_clipboard15 = require("@ai-matrx/kit/clipboard");
63121
- var import_core27 = require("@ai-matrx/print/core");
63157
+ var import_core28 = require("@ai-matrx/print/core");
63122
63158
  var import_markdown = require("@ai-matrx/print/markdown");
63123
63159
  init_objectActions();
63124
63160
  var NO_VIEW_REASON = "No saved view yet";
@@ -63243,7 +63279,7 @@ async function runTablePageAction(kind2, args) {
63243
63279
  }
63244
63280
  const page = (0, import_markdown.renderMarkdownDocument)(markdown, { title, withPrintActions: kind2 === "html-preview" });
63245
63281
  if (kind2 === "html-preview") {
63246
- (0, import_core27.openPrintWindow)(page, title);
63282
+ (0, import_core28.openPrintWindow)(page, title);
63247
63283
  if (note) args.host.notify?.success(note);
63248
63284
  } else if (kind2 === "copy-html-page") {
63249
63285
  if (await (0, import_clipboard15.copyText)(page)) args.host.notify?.success(note ?? "HTML page copied");