@ai-matrx/records-ui 0.116.42 → 0.116.44

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
@@ -996,14 +996,25 @@ function RefusalNotice({
996
996
  className,
997
997
  actions,
998
998
  onKeepEditing,
999
- onDiscard
999
+ onDiscard,
1000
+ onRetry
1000
1001
  }) {
1001
1002
  const archivedOrg = (0, import_core2.archivedOrganizationId)(error);
1002
1003
  if (archivedOrg) {
1003
1004
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ArchivedOrganizationNotice, { organizationId: archivedOrg, error, className });
1004
1005
  }
1005
1006
  const plain2 = refusalForAPerson(error);
1006
- const doors = onKeepEditing || onDiscard ? /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex flex-wrap items-center gap-1 pt-0.5", "data-refusal-doors": "", children: [
1007
+ const doors = onKeepEditing || onDiscard || onRetry ? /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex flex-wrap items-center gap-1 pt-0.5", "data-refusal-doors": "", children: [
1008
+ onRetry ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1009
+ "button",
1010
+ {
1011
+ type: "button",
1012
+ "data-refusal-retry": "",
1013
+ className: "rounded border px-2 py-0.5 text-xs hover:bg-muted",
1014
+ onClick: onRetry,
1015
+ children: "Try again"
1016
+ }
1017
+ ) : null,
1007
1018
  onKeepEditing ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1008
1019
  "button",
1009
1020
  {
@@ -4559,7 +4570,7 @@ function ImportWizard({ tableId, source, onDone, onWrote, autoRun, className })
4559
4570
  ] }) : /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { className: "text-muted-foreground", children: "Reading the rows this import refused\u2026" }) : null
4560
4571
  ] }, r.import_id)) })
4561
4572
  ] }) : null,
4562
- table.error ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(RefusalNotice, { error: table.error }) : null
4573
+ table.error ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(RefusalNotice, { error: table.error, onRetry: table.reload }) : null
4563
4574
  ] });
4564
4575
  }
4565
4576
  var import_react58, import_react59, import_core7, import_design_system31, import_records20, import_text_case5, import_jsx_runtime39, BATCH, SAMPLES, COLUMNS_PER_CALL, ABSENT, LEAVE, TITLE_COPY, TYPED_VALUES;
@@ -24261,7 +24272,7 @@ function DocTemplate({ tableId, seed, pageSettings, activeTemplateId, onActiveTe
24261
24272
  setActiveId(saved.data);
24262
24273
  await load();
24263
24274
  }
24264
- if (fields.error) return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(RefusalNotice, { error: fields.error, className });
24275
+ if (fields.error) return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(RefusalNotice, { error: fields.error, onRetry: fields.reload, className });
24265
24276
  if (error) {
24266
24277
  return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
24267
24278
  RefusalNotice,
@@ -28299,7 +28310,7 @@ function CustomRecordForm({
28299
28310
  () => fields.data ? (0, import_core15.predictWriteRefusals)({ fields: fields.data, document: document2, ...recordType ? { recordType } : {} }) : [],
28300
28311
  [fields.data, document2, recordType]
28301
28312
  );
28302
- if (fields.error) return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(RefusalNotice, { error: fields.error, className });
28313
+ if (fields.error) return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(RefusalNotice, { error: fields.error, onRetry: fields.reload, className });
28303
28314
  if (existing.error) return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(RefusalNotice, { error: existing.error, className });
28304
28315
  const storeSaid = said2.error && said2.error !== answered ? said2.error : null;
28305
28316
  const fieldProblems = predicted.filter((p) => p.field_key);
@@ -30422,7 +30433,7 @@ function AddLinkedDialog({
30422
30433
  "Add to ",
30423
30434
  column.source_table_name
30424
30435
  ] }) }),
30425
- fields.error ? /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(RefusalNotice, { error: fields.error }) : initial ? /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
30436
+ fields.error ? /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(RefusalNotice, { error: fields.error, onRetry: fields.reload }) : initial ? /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
30426
30437
  RecordForm,
30427
30438
  {
30428
30439
  tableId: column.source_table_id,
@@ -34749,8 +34760,8 @@ function GridBody({
34749
34760
  if (!embedded) rememberRowCount(`${tableId}:page:last`, rows.length);
34750
34761
  }
34751
34762
  }, [rowsAnswered, rowMemoryKey, rows.length, embedded, tableId]);
34752
- if (table.error) return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(RefusalNotice, { error: table.error, className });
34753
- if (fields.error) return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(RefusalNotice, { error: fields.error, className });
34763
+ if (table.error) return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(RefusalNotice, { error: table.error, onRetry: table.reload, className });
34764
+ if (fields.error) return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(RefusalNotice, { error: fields.error, onRetry: fields.reload, className });
34754
34765
  const nothingToShowYet = table.loading && !table.data || // No columns on a table whose level may hide them: not yet known which (one read, Confidential only).
34755
34766
  !structure.settled && (fields.data ?? []).length === 0 || fields.loading && !fields.data || !rights.known || rowRightsWaiting || records.loading && rows.length === 0 || // The page read has neither answered nor refused: nothing has been said yet, so nothing is empty.
34756
34767
  !records.data && !records.error || countedButNotReturned || manual && hand.loading && rows.length === 0;
@@ -34791,7 +34802,7 @@ function GridBody({
34791
34802
  } : {},
34792
34803
  children: [
34793
34804
  toolbarActions ? /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("div", { className: "flex items-center gap-2", "data-records-grid-actions": "", children: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("div", { className: "ml-auto flex items-center gap-1", children: toolbarActions }) }) : null,
34794
- records.error ? /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(RefusalNotice, { error: inColumnWords(records.error, fields.data ?? []) }) : null,
34805
+ records.error ? /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(RefusalNotice, { error: inColumnWords(records.error, fields.data ?? []), onRetry: records.reload }) : null,
34795
34806
  manual && hand.error ? /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(RefusalNotice, { error: hand.error }) : null,
34796
34807
  archived ? /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(
34797
34808
  "p",
@@ -36000,7 +36011,7 @@ function Peek({ tableId, recordId, onClose, className, onPage = false }) {
36000
36011
  if (fields.data) rememberRowCount(peekMemoryKey, shownFieldCount);
36001
36012
  }, [fields.data, peekMemoryKey, shownFieldCount]);
36002
36013
  if (record.error) return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(RefusalNotice, { error: record.error, className });
36003
- if (fields.error) return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(RefusalNotice, { error: fields.error, className });
36014
+ if (fields.error) return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(RefusalNotice, { error: fields.error, onRetry: fields.reload, className });
36004
36015
  const document2 = record.data?.document;
36005
36016
  if (document2 && (0, import_records51.isLockedStub)({ document: document2, level: null })) {
36006
36017
  const filed = document2["submitted_at"];
@@ -37359,7 +37370,7 @@ function ChecklistRunner({
37359
37370
  () => runs?.find((r) => r.run_id === activeId) ?? null,
37360
37371
  [runs, activeId]
37361
37372
  );
37362
- if (table.error) return /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(RefusalNotice, { error: table.error, className });
37373
+ if (table.error) return /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(RefusalNotice, { error: table.error, onRetry: table.reload, className });
37363
37374
  if (quietWhenEmpty && !runId) {
37364
37375
  const startable = mayStart && rights.write && (templates?.length ?? 0) > 0;
37365
37376
  if (runs === null || runs.length === 0 && !startable && !error && !said2) return null;
@@ -40004,8 +40015,8 @@ function TableSettingsPanel({
40004
40015
  const [deliberate, setDeliberate] = (0, import_react234.useState)(null);
40005
40016
  const [askingToRemove, setAskingToRemove] = (0, import_react234.useState)(null);
40006
40017
  const [enriching, setEnriching] = (0, import_react234.useState)(null);
40007
- if (table.error) return /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(RefusalNotice, { error: table.error, className });
40008
- if (fields.error) return /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(RefusalNotice, { error: fields.error, className });
40018
+ if (table.error) return /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(RefusalNotice, { error: table.error, onRetry: table.reload, className });
40019
+ if (fields.error) return /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(RefusalNotice, { error: fields.error, onRetry: fields.reload, className });
40009
40020
  if (!rights.structure) {
40010
40021
  if (tableIsLocked(table.data)) {
40011
40022
  return /* @__PURE__ */ (0, import_jsx_runtime137.jsxs)("div", { className: (0, import_design_system116.cn)("flex flex-col items-start gap-2 text-xs text-muted-foreground", className), "data-table-locked": "", children: [
@@ -40885,7 +40896,7 @@ function PipelineBoard({
40885
40896
  onMoved?.();
40886
40897
  void reload();
40887
40898
  };
40888
- if (fields.error) return /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(RefusalNotice, { error: fields.error });
40899
+ if (fields.error) return /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(RefusalNotice, { error: fields.error, onRetry: fields.reload });
40889
40900
  if (error) return /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(RefusalNotice, { error });
40890
40901
  if (loading || fields.loading && !fields.data) return /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(import_design_system118.Skeleton, { className: "h-40 w-full" });
40891
40902
  if (!definition?.is_pipeline) {
@@ -43665,8 +43676,14 @@ function ViewNeeds({ layout, tableId, fields, onMade, className }) {
43665
43676
  const choices = options.map((o) => o.trim()).filter((o) => o !== "");
43666
43677
  const suggestion = need.ask(name, choices);
43667
43678
  const make = async () => {
43679
+ const retrying = refused !== null || mutation.error !== null;
43668
43680
  setRefused(null);
43669
- const made = pendingId ?? await mutation.declare({
43681
+ let already = null;
43682
+ if (retrying && !pendingId) {
43683
+ const now = await client.fields({ table_id: tableId });
43684
+ if (now.ok) already = now.data.find((f) => fieldName(f) === name && !fields.some((g) => g.id === f.id))?.id ?? null;
43685
+ }
43686
+ const made = pendingId ?? already ?? await mutation.declare({
43670
43687
  table_id: tableId,
43671
43688
  spec: columnDeclarationFor(need, name, choices, fields)
43672
43689
  });
@@ -43746,8 +43763,8 @@ function ViewNeeds({ layout, tableId, fields, onMade, className }) {
43746
43763
  children: rights.structure ? `${need.missing} ${need.does(name)}` : need.missing
43747
43764
  }
43748
43765
  ),
43749
- mutation.error ? /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(RefusalNotice, { error: mutation.error }) : null,
43750
- refused ? /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(RefusalNotice, { error: refused }) : null,
43766
+ mutation.error ? /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(RefusalNotice, { error: mutation.error, onRetry: rights.structure ? () => void make() : void 0 }) : null,
43767
+ refused ? /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(RefusalNotice, { error: refused, onRetry: rights.structure ? () => void make() : void 0 }) : null,
43751
43768
  pendingId ? /* @__PURE__ */ (0, import_jsx_runtime144.jsx)("p", { className: "mt-2 text-xs text-muted-foreground", children: "The column was accepted but the table does not show it yet. Press Make it work again to look for it \u2014 it will not be added twice." }) : null
43752
43769
  ] });
43753
43770
  }
@@ -46916,8 +46933,8 @@ function Board({
46916
46933
  tableId: view.subject,
46917
46934
  needed: viewQuestionAsked && !records.loading && records.rows.length === 0
46918
46935
  });
46919
- if (fields.error) return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(RefusalNotice, { error: fields.error });
46920
- if (records.error) return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(RefusalNotice, { error: records.error });
46936
+ if (fields.error) return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(RefusalNotice, { error: fields.error, onRetry: fields.reload });
46937
+ if (records.error) return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(RefusalNotice, { error: records.error, onRetry: records.reload });
46921
46938
  if (fields.loading && !fields.data || records.loading && records.rows.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(RecordsSkeleton, { layout: view.layout });
46922
46939
  const all = fields.data ?? [];
46923
46940
  const byKey = (key) => all.find((f) => f.key === key);
@@ -52506,7 +52523,7 @@ function ConnectedFormRunner(props) {
52506
52523
  },
52507
52524
  [client, form.subject, form.questions, form.endings]
52508
52525
  );
52509
- if (fields.error) return /* @__PURE__ */ (0, import_jsx_runtime171.jsx)(RefusalNotice, { error: fields.error, className });
52526
+ if (fields.error) return /* @__PURE__ */ (0, import_jsx_runtime171.jsx)(RefusalNotice, { error: fields.error, onRetry: fields.reload, className });
52510
52527
  if (fields.loading && !fields.data) return /* @__PURE__ */ (0, import_jsx_runtime171.jsx)(import_design_system147.Skeleton, { className: (0, import_design_system147.cn)("h-40 w-full", className) });
52511
52528
  return /* @__PURE__ */ (0, import_jsx_runtime171.jsx)(
52512
52529
  FormStage,
@@ -53400,7 +53417,7 @@ function FormBuilder({ tableId, seed, activeFormId, onActiveForm, startWithOne,
53400
53417
  (made) => setMakeOnMount(made ? "made" : "not-made")
53401
53418
  );
53402
53419
  }, [createOnMount, makeOnMount, forms, fields.data, create, table.data, table.error]);
53403
- if (fields.error) return /* @__PURE__ */ (0, import_jsx_runtime172.jsx)(RefusalNotice, { error: fields.error, className });
53420
+ if (fields.error) return /* @__PURE__ */ (0, import_jsx_runtime172.jsx)(RefusalNotice, { error: fields.error, onRetry: fields.reload, className });
53404
53421
  if (error) {
53405
53422
  return /* @__PURE__ */ (0, import_jsx_runtime172.jsx)(
53406
53423
  RefusalNotice,
@@ -54287,7 +54304,7 @@ function SignBlock({ tableId, recordId, render, className }) {
54287
54304
  setName("");
54288
54305
  await load();
54289
54306
  }
54290
- if (fields.error) return /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(RefusalNotice, { error: fields.error, className });
54307
+ if (fields.error) return /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(RefusalNotice, { error: fields.error, onRetry: fields.reload, className });
54291
54308
  if (error) {
54292
54309
  return /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(
54293
54310
  RefusalNotice,
@@ -59245,8 +59262,8 @@ function AdHocCaptureSheet({
59245
59262
  await keep([...queue.current, item]);
59246
59263
  await flush();
59247
59264
  }
59248
- if (table.error) return /* @__PURE__ */ (0, import_jsx_runtime186.jsx)(RefusalNotice, { error: table.error, className });
59249
- if (fields.error) return /* @__PURE__ */ (0, import_jsx_runtime186.jsx)(RefusalNotice, { error: fields.error, className });
59265
+ if (table.error) return /* @__PURE__ */ (0, import_jsx_runtime186.jsx)(RefusalNotice, { error: table.error, onRetry: table.reload, className });
59266
+ if (fields.error) return /* @__PURE__ */ (0, import_jsx_runtime186.jsx)(RefusalNotice, { error: fields.error, onRetry: fields.reload, className });
59250
59267
  if (fields.loading || pending === null) return /* @__PURE__ */ (0, import_jsx_runtime186.jsx)(import_design_system163.Skeleton, { className: (0, import_design_system163.cn)("h-64 w-full", className) });
59251
59268
  const keys = resolved();
59252
59269
  return /* @__PURE__ */ (0, import_jsx_runtime186.jsxs)("section", { className: (0, import_design_system163.cn)("mx-auto flex w-full max-w-sm flex-col gap-2", className), children: [
@@ -59619,7 +59636,7 @@ function EmbedFrame({
59619
59636
  setSecret(null);
59620
59637
  setTokenId(null);
59621
59638
  }, [client, tokenId]);
59622
- if (table.error) return /* @__PURE__ */ (0, import_jsx_runtime189.jsx)(RefusalNotice, { error: table.error, className });
59639
+ if (table.error) return /* @__PURE__ */ (0, import_jsx_runtime189.jsx)(RefusalNotice, { error: table.error, onRetry: table.reload, className });
59623
59640
  if (table.loading && !table.data) return /* @__PURE__ */ (0, import_jsx_runtime189.jsx)(import_design_system166.Skeleton, { className: (0, import_design_system166.cn)("h-48 w-full", className) });
59624
59641
  if (!rights.admin) {
59625
59642
  return /* @__PURE__ */ (0, import_jsx_runtime189.jsxs)("p", { className: (0, import_design_system166.cn)("rounded border border-dashed px-2 py-1 text-xs text-muted-foreground", className), children: [
@@ -61862,7 +61879,7 @@ function TablePage({
61862
61879
  const headerNode = header && !embedded ? header({ actions: table.data ? pageActions : null, tableName: table.data?.name ?? null }) : null;
61863
61880
  if (table.error) return /* @__PURE__ */ (0, import_jsx_runtime198.jsxs)(import_jsx_runtime198.Fragment, { children: [
61864
61881
  headerNode,
61865
- /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(RefusalNotice, { error: table.error })
61882
+ /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(RefusalNotice, { error: table.error, onRetry: table.reload })
61866
61883
  ] });
61867
61884
  if (table.loading && !table.data) {
61868
61885
  return /* @__PURE__ */ (0, import_jsx_runtime198.jsxs)(import_jsx_runtime198.Fragment, { children: [