@ai-matrx/records-ui 0.116.41 → 0.116.43

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.
@@ -54,7 +54,7 @@ import {
54
54
  useRecordsUi,
55
55
  useTableRights,
56
56
  withoutInternalCodes
57
- } from "./chunk-5IHVQ5MS.js";
57
+ } from "./chunk-KEILC5XG.js";
58
58
  import {
59
59
  kindItemWords,
60
60
  kindLabel,
@@ -4784,7 +4784,7 @@ import { AlchemyMenu } from "@ai-matrx/alchemy/react";
4784
4784
  import { OutboundLink as OutboundLink5 } from "@ai-matrx/kit/outbound-react";
4785
4785
  import { humanizeIdentifier } from "@ai-matrx/kit/text-case";
4786
4786
  import { jsx as jsx26, jsxs as jsxs22 } from "react/jsx-runtime";
4787
- var SaveToTable = lazy(() => import("./SaveToTable-T2CMF2SK.js").then((m) => ({ default: m.SaveToTable })));
4787
+ var SaveToTable = lazy(() => import("./SaveToTable-4B67TPSC.js").then((m) => ({ default: m.SaveToTable })));
4788
4788
  var LONGEST_READ = 5e5;
4789
4789
  var FENCE = /^```(?:json)?[ \t]*\r?\n([\s\S]*?)\r?\n?```$/;
4790
4790
  function isPlainObject(v) {
@@ -12325,4 +12325,4 @@ export {
12325
12325
  RecordNameText,
12326
12326
  HeldChangeDecision
12327
12327
  };
12328
- //# sourceMappingURL=chunk-JKM6DDSD.js.map
12328
+ //# sourceMappingURL=chunk-THRMANHB.js.map
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
  {
@@ -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
  }
@@ -56943,6 +56960,9 @@ function CsvButton({ name, fields, rows }) {
56943
56960
  if (rows.length === 0) return null;
56944
56961
  return /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(import_design_system158.Button, { size: "sm", variant: "ghost", className: "h-7 text-xs", onClick: () => downloadCsv(name, fields, rows), "data-records-page-csv": "", children: "CSV" });
56945
56962
  }
56963
+ function sameRows(had, rows) {
56964
+ return had === rows || had !== void 0 && had.length === 0 && rows.length === 0;
56965
+ }
56946
56966
  function PageCanvas({ blocks, charts, run, subject, viewerUserId, editing, canEdit, onSave, onChart }) {
56947
56967
  const [selected, setSelected] = (0, import_react317.useState)({});
56948
56968
  const [listRows, setListRows] = (0, import_react317.useState)({});
@@ -56990,7 +57010,7 @@ function PageCanvas({ blocks, charts, run, subject, viewerUserId, editing, canEd
56990
57010
  viewerUserId,
56991
57011
  selected,
56992
57012
  onSelect: (listId, recordId) => setSelected((s) => ({ ...s, [listId]: recordId })),
56993
- onRows: (listId, rows) => setListRows((r) => r[listId] === rows ? r : { ...r, [listId]: rows }),
57013
+ onRows: (listId, rows) => setListRows((r) => sameRows(r[listId], rows) ? r : { ...r, [listId]: rows }),
56994
57014
  listRows,
56995
57015
  listOf,
56996
57016
  extraFor: filtersFor,
@@ -57182,6 +57202,7 @@ var DEFAULT_COLUMNS = 4;
57182
57202
  function shownColumns(all, columns) {
57183
57203
  return columns && columns.length > 0 ? columns.map((k) => all.find((f) => f.key === k)).filter((f) => !!f) : [...all].sort((a, b) => (a.sort ?? 100) - (b.sort ?? 100)).slice(0, DEFAULT_COLUMNS);
57184
57204
  }
57205
+ var NO_ROWS4 = [];
57185
57206
  function useElementRows(block, viewerUserId, extra, mineOn) {
57186
57207
  const door = useInterfaceDoor();
57187
57208
  const member = useMemberRows(block, viewerUserId, extra, mineOn, !door);
@@ -57202,7 +57223,7 @@ function useElementRows(block, viewerUserId, extra, mineOn) {
57202
57223
  }
57203
57224
  const { q, page } = member;
57204
57225
  return {
57205
- rows: q.nobodyIsMe ? [] : page.data?.rows ?? [],
57226
+ rows: q.nobodyIsMe ? NO_ROWS4 : page.data?.rows ?? NO_ROWS4,
57206
57227
  all: q.all,
57207
57228
  total: q.nobodyIsMe ? 0 : page.data?.total ?? null,
57208
57229
  loading: page.loading,