@nivaro/react 0.3.46 → 0.3.47

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.
Files changed (57) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +248 -16
  4. package/dist/index.js +679 -659
  5. package/dist/shared/components/CollectionBrowserView.js +813 -826
  6. package/dist/shared/components/ErrorNotice.js +169 -0
  7. package/dist/shared/components/ErrorSurface.js +23 -17
  8. package/dist/shared/components/ListLoadError.js +8 -29
  9. package/dist/shared/components/LoadErrorNote.js +38 -21
  10. package/dist/shared/components/QueryErrorState.js +8 -11
  11. package/dist/shared/components/ReportView.js +1320 -1291
  12. package/dist/shared/components/chat/ChannelArchive.js +60 -60
  13. package/dist/shared/components/chat/ChannelExtras.js +74 -74
  14. package/dist/shared/components/chat/ChatPanel.js +368 -367
  15. package/dist/shared/components/command-center/PeekPanel.js +33 -32
  16. package/dist/shared/components/command-center/panels/BoardSettings.js +41 -40
  17. package/dist/shared/components/command-center/panels/PeoplePanel.js +32 -31
  18. package/dist/shared/components/help-videos/editor/ClipsPanel.js +49 -48
  19. package/dist/shared/components/help-videos/editor/PublishButton.js +37 -36
  20. package/dist/shared/components/help-videos/editor/StatsTab.js +45 -44
  21. package/dist/shared/components/help-videos/editor/VersionsTab.js +29 -28
  22. package/dist/shared/components/help-videos/library/AuthorRolesButton.js +19 -18
  23. package/dist/shared/components/help-videos/library/HelpVideoLibrary.js +132 -129
  24. package/dist/shared/components/help-videos/library/LearningPathsPanel.js +42 -41
  25. package/dist/shared/components/help-videos/settings/HouseStyleButton.js +21 -20
  26. package/dist/shared/components/help-videos/settings/RenderSettingsButton.js +22 -21
  27. package/dist/shared/components/import/DocumentAutofillButton.js +24 -20
  28. package/dist/shared/components/import/ImportFromFileButton.js +61 -60
  29. package/dist/shared/components/imports/ImportStalenessControl.js +20 -21
  30. package/dist/shared/components/imports/NewImportDialog.js +29 -28
  31. package/dist/shared/components/imports/RunDetailSheet.js +63 -63
  32. package/dist/shared/components/item-edit/FieldRow.js +329 -329
  33. package/dist/shared/components/item-edit/InlineTableField.js +898 -898
  34. package/dist/shared/components/item-edit/PersonalDefaultControl.js +57 -56
  35. package/dist/shared/components/item-edit/PlanGrid.js +220 -221
  36. package/dist/shared/components/item-edit/RecordGrantTools.js +49 -48
  37. package/dist/shared/components/item-edit/placement-behaviour.js +68 -67
  38. package/dist/shared/components/layout-editor/inspector/ColumnFit.js +24 -23
  39. package/dist/shared/components/layout-editor/inspector/PickerPreview.js +17 -16
  40. package/dist/shared/components/layout-editor/matrix/FieldStateMatrix.js +41 -41
  41. package/dist/shared/components/layout-editor/outputs/output-api.js +33 -31
  42. package/dist/shared/components/layout-editor/overview/overview-api.js +84 -83
  43. package/dist/shared/components/layout-editor/useLayoutDraft.js +47 -42
  44. package/dist/shared/components/monitoring/InactiveUserLinksView.js +10 -9
  45. package/dist/shared/components/panels/SlaClock.js +35 -36
  46. package/dist/shared/components/pipeline/PipelineEditorView.js +311 -312
  47. package/dist/shared/components/pipeline/TeamSuggestions.js +31 -30
  48. package/dist/shared/components/profile/AgentsPanel.js +73 -72
  49. package/dist/shared/components/profile/MailSuppressedPill.js +22 -21
  50. package/dist/shared/components/support/SupportRequestDialog.js +85 -81
  51. package/dist/shared/components/support/SupportView.js +94 -87
  52. package/dist/shared/lib/autofill-poll.js +21 -18
  53. package/dist/shared/lib/error-actions.js +85 -0
  54. package/dist/shared/lib/error-message.js +223 -82
  55. package/dist/shared/lib/error-toast.js +71 -13
  56. package/dist/shared/lib/safe-error.js +136 -38
  57. package/package.json +1 -1
@@ -2,18 +2,18 @@ import { jsxs as h, jsx as r, Fragment as J } from "react/jsx-runtime";
2
2
  import { useState as Q, useMemo as P } from "react";
3
3
  import { toast as O } from "sonner";
4
4
  import { HEADER_GROUP_KEY as _ } from "../../../lib/layout-ops.js";
5
- import { userErrorMessage as X } from "../../../lib/safe-error.js";
6
- import { cn as F } from "../../../lib/utils.js";
7
- import { Skeleton as ee } from "../../ui/skeleton.js";
8
- import { targetOfKey as te, keyOf as re, isFieldRow as T, fieldZones as oe, zoneItems as ne } from "../field-zones.js";
9
- import { resetPlacementOps as le } from "../inheritance.js";
10
- import { useCollectionMeta as ae } from "../inspector/field-context.js";
11
- import { overridePlacementOps as se, describeField as ie } from "../inspector/model.js";
12
- import { LoadError as de } from "../load-error.js";
13
- import { useCollectionPipelines as ce } from "../preview/preview-api.js";
14
- import { useCellMenu as me, MatrixMenu as ue, matrixCorner as he, matrixTh as H, matrixRowHead as fe, InheritChip as pe, matrixCellTd as Z, MatrixCellButton as j, matrixZoneTd as we } from "./MatrixGrid.js";
15
- import { useSaveRequirements as be } from "./matrix-api.js";
16
- import { CELL_KINDS as z, stateCell as K, movesFrom as ge, everyStateValue as L, everyStateOps as xe, cellChange as ye } from "./state-matrix.js";
5
+ import { plainErrorText as X, userErrorMessage as ee } from "../../../lib/safe-error.js";
6
+ import { cn as T } from "../../../lib/utils.js";
7
+ import { Skeleton as te } from "../../ui/skeleton.js";
8
+ import { targetOfKey as re, keyOf as oe, isFieldRow as F, fieldZones as ne, zoneItems as le } from "../field-zones.js";
9
+ import { resetPlacementOps as ae } from "../inheritance.js";
10
+ import { useCollectionMeta as se } from "../inspector/field-context.js";
11
+ import { overridePlacementOps as ie, describeField as de } from "../inspector/model.js";
12
+ import { LoadError as ce } from "../load-error.js";
13
+ import { useCollectionPipelines as me } from "../preview/preview-api.js";
14
+ import { useCellMenu as ue, MatrixMenu as he, matrixCorner as fe, matrixTh as H, matrixRowHead as pe, InheritChip as we, matrixCellTd as Z, MatrixCellButton as j, matrixZoneTd as be } from "./MatrixGrid.js";
15
+ import { useSaveRequirements as ge } from "./matrix-api.js";
16
+ import { CELL_KINDS as z, stateCell as K, movesFrom as xe, everyStateValue as L, everyStateOps as ye, cellChange as ve } from "./state-matrix.js";
17
17
  const x = {
18
18
  normal: "Editable",
19
19
  readonly: "Read-only",
@@ -25,18 +25,18 @@ const x = {
25
25
  required: "required",
26
26
  hidden: "hidden"
27
27
  }, D = "*", A = (o) => `${o.field}${o.group_key ?? ""}`;
28
- function ve(o, a) {
28
+ function ke(o, a) {
29
29
  const f = new Set((a == null ? void 0 : a.placements.map((n) => n.field)) ?? []), p = (n) => ({
30
30
  row: n,
31
31
  source: f.has(n.field) ? "override" : "own"
32
- }), v = [], g = o.placements.filter((n) => n.group_key === _ && T(n)).sort((n, w) => n.sort - w.sort);
32
+ }), v = [], g = o.placements.filter((n) => n.group_key === _ && F(n)).sort((n, w) => n.sort - w.sort);
33
33
  g.length && v.push({ key: _, label: "Header strip", rows: g.map(p) });
34
- for (const n of oe(o)) {
35
- const w = ne(o, n.key).filter(T);
34
+ for (const n of ne(o)) {
35
+ const w = le(o, n.key).filter(F);
36
36
  w.length && v.push({ key: n.key ?? "", label: n.label, rows: w.map(p) });
37
37
  }
38
38
  if (a) {
39
- const n = new Set(o.placements.map((b) => b.field)), w = /* @__PURE__ */ new Set(), C = a.placements.filter((b) => !T(b) || n.has(b.field) || w.has(b.field) ? !1 : (w.add(b.field), !0));
39
+ const n = new Set(o.placements.map((b) => b.field)), w = /* @__PURE__ */ new Set(), C = a.placements.filter((b) => !F(b) || n.has(b.field) || w.has(b.field) ? !1 : (w.add(b.field), !0));
40
40
  C.length && v.push({
41
41
  key: "parent",
42
42
  label: `From ${String(a.layout.name ?? "the parent layout")}`,
@@ -45,19 +45,19 @@ function ve(o, a) {
45
45
  }
46
46
  return v;
47
47
  }
48
- function He({
48
+ function Ze({
49
49
  bundle: o,
50
50
  parent: a,
51
51
  collection: f,
52
52
  apply: p,
53
53
  onSelect: v
54
54
  }) {
55
- const { data: g } = ae(f), {
55
+ const { data: g } = se(f), {
56
56
  data: n = [],
57
57
  isLoading: w,
58
58
  isError: C,
59
59
  refetch: b
60
- } = ce(f, !0), [V, W] = Q(null), s = n.find((e) => e.id === V) ?? n[0] ?? null, k = (s == null ? void 0 : s.states) ?? [], N = (s == null ? void 0 : s.transitions) ?? [], M = be(f), y = me(), R = P(() => ve(o, a), [o, a]), q = String((a == null ? void 0 : a.layout.name) ?? "the parent layout"), E = (e) => ie(e.field, (g == null ? void 0 : g.fields) ?? [], (g == null ? void 0 : g.relations) ?? [], e).label, l = P(() => {
60
+ } = me(f, !0), [V, W] = Q(null), s = n.find((e) => e.id === V) ?? n[0] ?? null, k = (s == null ? void 0 : s.states) ?? [], N = (s == null ? void 0 : s.transitions) ?? [], M = ge(f), y = ue(), R = P(() => ke(o, a), [o, a]), q = String((a == null ? void 0 : a.layout.name) ?? "the parent layout"), E = (e) => de(e.field, (g == null ? void 0 : g.fields) ?? [], (g == null ? void 0 : g.relations) ?? [], e).label, l = P(() => {
61
61
  if (!y.open) return null;
62
62
  const e = y.open.lastIndexOf("|"), t = y.open.slice(0, e), d = y.open.slice(e + 1);
63
63
  for (const c of R)
@@ -73,7 +73,7 @@ function He({
73
73
  blocked: null
74
74
  })) : (() => {
75
75
  var m;
76
- const e = l.state, t = K(l.row, e, N), d = ge(N, e), c = d.length === 1 ? `"${(m = d[0]) == null ? void 0 : m.label}"` : `the ${d.length} moves out`;
76
+ const e = l.state, t = K(l.row, e, N), d = xe(N, e), c = d.length === 1 ? `"${(m = d[0]) == null ? void 0 : m.label}"` : `the ${d.length} moves out`;
77
77
  return z.map((i) => {
78
78
  const u = t.options[i];
79
79
  return {
@@ -88,12 +88,12 @@ function He({
88
88
  if (!l) return;
89
89
  const t = E(l.row);
90
90
  if (l.state == null) {
91
- const m = xe(l.row, e);
91
+ const m = ye(l.row, e);
92
92
  m.length && p(m, { label: `${t}: ${x[e].toLowerCase()} on every state` });
93
93
  return;
94
94
  }
95
95
  if (!s) return;
96
- const d = l.state, c = ye(l.row, d, s.id, N, e);
96
+ const d = l.state, c = ve(l.row, d, s.id, N, e);
97
97
  if (c && (c.ops.length && p(c.ops, { label: `${t}: ${x[e].toLowerCase()} in ${d.label}` }), c.requirements.length !== 0))
98
98
  try {
99
99
  await M(c.requirements);
@@ -133,7 +133,7 @@ function He({
133
133
  type: "button",
134
134
  "aria-pressed": e.id === (s == null ? void 0 : s.id),
135
135
  onClick: () => W(e.id),
136
- className: F(
136
+ className: T(
137
137
  "inline-flex h-7 items-center rounded px-2 text-[12px] font-medium transition-colors",
138
138
  e.id === (s == null ? void 0 : s.id) ? "bg-white text-slate-900 shadow-sm dark:bg-background dark:text-foreground" : "text-slate-500 hover:text-slate-800 dark:text-muted-foreground dark:hover:text-foreground"
139
139
  ),
@@ -144,7 +144,7 @@ function He({
144
144
  }
145
145
  )
146
146
  ] }),
147
- C ? /* @__PURE__ */ r(de, { what: "the workflow states", onRetry: () => void b() }) : !w && !s && /* @__PURE__ */ r(
147
+ C ? /* @__PURE__ */ r(ce, { what: "the workflow states", onRetry: () => void b() }) : !w && !s && /* @__PURE__ */ r(
148
148
  "p",
149
149
  {
150
150
  role: "note",
@@ -152,8 +152,8 @@ function He({
152
152
  children: "No pipeline runs on this collection, so only Every state applies."
153
153
  }
154
154
  ),
155
- w ? /* @__PURE__ */ r(ee, { className: "h-48 w-full rounded-lg" }) : /* @__PURE__ */ r(
156
- ue,
155
+ w ? /* @__PURE__ */ r(te, { className: "h-48 w-full rounded-lg" }) : /* @__PURE__ */ r(
156
+ he,
157
157
  {
158
158
  menu: y,
159
159
  title: l ? `${E(l.row)} · ${l.state ? l.state.label : "Every state"}` : "",
@@ -162,11 +162,11 @@ function He({
162
162
  onPick: (e) => void G(e),
163
163
  children: /* @__PURE__ */ r("div", { className: "min-h-0 flex-1 overflow-auto rounded-lg border border-slate-200 bg-white dark:border-border dark:bg-card", children: /* @__PURE__ */ h("table", { className: "border-separate border-spacing-0 text-[12.5px]", children: [
164
164
  /* @__PURE__ */ r("thead", { children: /* @__PURE__ */ h("tr", { children: [
165
- /* @__PURE__ */ r("th", { className: he, children: "Field" }),
165
+ /* @__PURE__ */ r("th", { className: fe, children: "Field" }),
166
166
  /* @__PURE__ */ r(
167
167
  "th",
168
168
  {
169
- className: F(H, "text-center"),
169
+ className: T(H, "text-center"),
170
170
  "data-tip": "The field on this form, whatever the state",
171
171
  children: "Every state"
172
172
  }
@@ -174,7 +174,7 @@ function He({
174
174
  k.map((e) => /* @__PURE__ */ r(
175
175
  "th",
176
176
  {
177
- className: F(H, "text-center"),
177
+ className: T(H, "text-center"),
178
178
  "data-matrix-state": e.key,
179
179
  children: /* @__PURE__ */ h("span", { className: "inline-flex items-center gap-1.5", children: [
180
180
  /* @__PURE__ */ r(
@@ -193,19 +193,19 @@ function He({
193
193
  ] }) }),
194
194
  /* @__PURE__ */ h("tbody", { children: [
195
195
  R.map((e) => /* @__PURE__ */ r(
196
- ke,
196
+ $e,
197
197
  {
198
198
  zone: e,
199
199
  colSpan: k.length + 1,
200
200
  render: (t) => {
201
201
  const d = E(t.row), c = A(t.row), m = t.source === "inherited" ? `From ${q} — override it to change it here` : null, i = L(t.row);
202
202
  return /* @__PURE__ */ h("tr", { "data-matrix-row": t.row.field, children: [
203
- /* @__PURE__ */ h("th", { scope: "row", className: fe, children: [
203
+ /* @__PURE__ */ h("th", { scope: "row", className: pe, children: [
204
204
  /* @__PURE__ */ r(
205
205
  "button",
206
206
  {
207
207
  type: "button",
208
- onClick: (u) => v(te(re(t.row)), {
208
+ onClick: (u) => v(re(oe(t.row)), {
209
209
  additive: u.shiftKey || u.metaKey || u.ctrlKey
210
210
  }),
211
211
  "data-tip": "Select it on the form",
@@ -214,16 +214,16 @@ function He({
214
214
  }
215
215
  ),
216
216
  t.source !== "own" && a && /* @__PURE__ */ r(
217
- pe,
217
+ we,
218
218
  {
219
219
  kind: t.source === "inherited" ? "inherited" : "override",
220
220
  parentName: q,
221
221
  action: t.source === "inherited" ? "override" : "reset",
222
222
  actionLabel: t.source === "inherited" ? `Override ${d} on this form` : `Reset ${d} to ${q}`,
223
223
  actionTip: t.source === "inherited" ? "Copy it onto this form to change it here" : `Take ${q}'s placement of it again`,
224
- onAction: () => t.source === "inherited" ? p(se(o, a, t.row), {
224
+ onAction: () => t.source === "inherited" ? p(ie(o, a, t.row), {
225
225
  label: `Override ${d} on this form`
226
- }) : p(le(o, t.row.field), {
226
+ }) : p(ae(o, t.row.field), {
227
227
  label: `Reset ${d} to ${q}`
228
228
  })
229
229
  }
@@ -276,14 +276,14 @@ function He({
276
276
  )
277
277
  ] });
278
278
  }
279
- function ke({
279
+ function $e({
280
280
  zone: o,
281
281
  colSpan: a,
282
282
  render: f
283
283
  }) {
284
284
  return /* @__PURE__ */ h(J, { children: [
285
285
  /* @__PURE__ */ h("tr", { "data-matrix-zone": o.key, children: [
286
- /* @__PURE__ */ r("td", { className: we, children: o.label }),
286
+ /* @__PURE__ */ r("td", { className: be, children: o.label }),
287
287
  /* @__PURE__ */ r(
288
288
  "td",
289
289
  {
@@ -298,9 +298,9 @@ function ke({
298
298
  function U(o) {
299
299
  var f, p;
300
300
  const a = (p = (f = o == null ? void 0 : o.response) == null ? void 0 : f.data) == null ? void 0 : p.error;
301
- return typeof a == "string" ? a : X(o, "Something went wrong");
301
+ return typeof a == "string" ? X(a) : ee(o, "Something went wrong");
302
302
  }
303
303
  export {
304
- He as FieldStateMatrix,
305
- ve as matrixZones
304
+ Ze as FieldStateMatrix,
305
+ ke as matrixZones
306
306
  };
@@ -1,56 +1,58 @@
1
- var d = Object.defineProperty;
2
- var p = (e, t, a) => t in e ? d(e, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : e[t] = a;
1
+ var u = Object.defineProperty;
2
+ var p = (e, t, a) => t in e ? u(e, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : e[t] = a;
3
3
  var l = (e, t, a) => p(e, typeof t != "symbol" ? t + "" : t, a);
4
- async function r(e) {
5
- let t = `Something went wrong (${e.status})`;
4
+ import { statusTitle as i } from "../../../lib/safe-error.js";
5
+ async function s(e) {
6
+ let t = i(e.status) ?? "Something went wrong", a = null;
6
7
  try {
7
- const a = await e.json();
8
- a.error && (t = a.error);
8
+ a = await e.json();
9
+ const o = a == null ? void 0 : a.error;
10
+ o && (t = o);
9
11
  } catch {
10
12
  }
11
- return new Error(t);
13
+ return Object.assign(new Error(t), { status: e.status, response: a });
12
14
  }
13
- function i(e, t) {
15
+ function c(e, t) {
14
16
  const a = /filename="([^"]+)"/.exec(e.headers.get("Content-Disposition") ?? "");
15
17
  return (a == null ? void 0 : a[1]) ?? t;
16
18
  }
17
- async function s(e, t, a) {
19
+ async function r(e, t, a) {
18
20
  const o = await fetch(`${e.apiBase}${t}`, {
19
21
  headers: e.authHeaders,
20
22
  credentials: e.credentials
21
23
  });
22
- if (!o.ok) throw await r(o);
23
- return { blob: await o.blob(), filename: i(o, a) };
24
+ if (!o.ok) throw await s(o);
25
+ return { blob: await o.blob(), filename: c(o, a) };
24
26
  }
25
- async function c(e, t, a, o) {
27
+ async function d(e, t, a, o) {
26
28
  const n = await fetch(`${e.apiBase}${t}`, {
27
29
  method: "POST",
28
30
  headers: { ...e.authHeaders, "Content-Type": "application/json" },
29
31
  credentials: e.credentials,
30
32
  body: JSON.stringify(a)
31
33
  });
32
- if (!n.ok) throw await r(n);
33
- return { blob: await n.blob(), filename: i(n, o) };
34
+ if (!n.ok) throw await s(n);
35
+ return { blob: await n.blob(), filename: c(n, o) };
34
36
  }
35
- const w = (e, t) => s(e, `/collection-layouts/${t}/spreadsheet-template`, "template.xlsx"), f = (e, t, a = 5e3) => c(e, `/collection-layouts/${t}/spreadsheet-export`, { limit: a }, "records.xlsx"), b = (e, t) => s(e, `/collection-layouts/${t}/blank-form`, "blank-form.pdf"), m = (e, t, a) => c(e, "/collection-layouts/help-sheet/xlsx", { rows: t, name: a }, "help-text.xlsx");
36
- async function u(e) {
37
+ const m = (e, t) => r(e, `/collection-layouts/${t}/spreadsheet-template`, "template.xlsx"), b = (e, t, a = 5e3) => d(e, `/collection-layouts/${t}/spreadsheet-export`, { limit: a }, "records.xlsx"), x = (e, t) => r(e, `/collection-layouts/${t}/blank-form`, "blank-form.pdf"), S = (e, t, a) => d(e, "/collection-layouts/help-sheet/xlsx", { rows: t, name: a }, "help-text.xlsx");
38
+ async function h(e) {
37
39
  const t = new Uint8Array(await e.arrayBuffer());
38
40
  let a = "";
39
41
  for (let o = 0; o < t.length; o += 32768)
40
42
  a += String.fromCharCode(...t.subarray(o, o + 32768));
41
43
  return btoa(a);
42
44
  }
43
- async function x(e, t) {
45
+ async function $(e, t) {
44
46
  const a = await fetch(`${e.apiBase}/collection-layouts/help-sheet/parse`, {
45
47
  method: "POST",
46
48
  headers: { ...e.authHeaders, "Content-Type": "application/json" },
47
49
  credentials: e.credentials,
48
- body: JSON.stringify({ file: await u(t) })
50
+ body: JSON.stringify({ file: await h(t) })
49
51
  });
50
- if (!a.ok) throw await r(a);
52
+ if (!a.ok) throw await s(a);
51
53
  return (await a.json()).data.rows;
52
54
  }
53
- const $ = (e, t) => s(e, `/collection-layouts/${t}/file?download=1`, "layout.layout.yaml");
55
+ const j = (e, t) => r(e, `/collection-layouts/${t}/file?download=1`, "layout.layout.yaml");
54
56
  class y extends Error {
55
57
  constructor(a, o) {
56
58
  super(a);
@@ -58,7 +60,7 @@ class y extends Error {
58
60
  this.problems = o;
59
61
  }
60
62
  }
61
- async function S(e, t, a) {
63
+ async function O(e, t, a) {
62
64
  const o = await fetch(`${e.apiBase}/collection-layouts/${t}/file/parse`, {
63
65
  method: "POST",
64
66
  headers: { ...e.authHeaders, "Content-Type": "application/json" },
@@ -72,24 +74,24 @@ async function S(e, t, a) {
72
74
  } catch {
73
75
  }
74
76
  throw new y(
75
- n.error ?? `Something went wrong (${o.status})`,
77
+ n.error ?? i(o.status) ?? "Something went wrong",
76
78
  Array.isArray(n.problems) ? n.problems : []
77
79
  );
78
80
  }
79
81
  return (await o.json()).data;
80
82
  }
81
- function j({ blob: e, filename: t }) {
83
+ function k({ blob: e, filename: t }) {
82
84
  const a = URL.createObjectURL(e), o = document.createElement("a");
83
85
  o.href = a, o.download = t, document.body.appendChild(o), o.click(), o.remove(), setTimeout(() => URL.revokeObjectURL(a), 1e3);
84
86
  }
85
87
  export {
86
88
  y as LayoutFileProblems,
87
- b as downloadBlankForm,
88
- m as downloadHelpSheet,
89
- $ as downloadLayoutFile,
90
- f as downloadRecords,
91
- w as downloadTemplate,
92
- x as parseHelpSheetFile,
93
- S as parseLayoutFile,
94
- j as saveFile
89
+ x as downloadBlankForm,
90
+ S as downloadHelpSheet,
91
+ j as downloadLayoutFile,
92
+ b as downloadRecords,
93
+ m as downloadTemplate,
94
+ $ as parseHelpSheetFile,
95
+ O as parseLayoutFile,
96
+ k as saveFile
95
97
  };
@@ -1,158 +1,159 @@
1
- import { useQuery as h, useQueryClient as _, useQueries as K } from "@tanstack/react-query";
2
- import { useCallback as S, useMemo as g } from "react";
3
- import { useNivaroClient as p, useItemEditAuth as T } from "../../../context.js";
4
- import { get as d } from "../../../lib/commands.js";
5
- import { USER_SYSTEM_COLS as w, userDisplayLabel as C, renderDisplayTemplate as $ } from "../../pipeline/relations.js";
6
- import { collectionMetaKey as L, useCollectionBody as F } from "../collection-meta.js";
7
- import { choiceLabelsFrom as O } from "./describe-conditions.js";
8
- import { recordCountFilter as A } from "./record-count.js";
1
+ import { useQuery as h, useQueryClient as T, useQueries as F } from "@tanstack/react-query";
2
+ import { useCallback as K, useMemo as g } from "react";
3
+ import { useNivaroClient as p, useItemEditAuth as S } from "../../../context.js";
4
+ import { get as m } from "../../../lib/commands.js";
5
+ import { plainErrorText as w } from "../../../lib/safe-error.js";
6
+ import { USER_SYSTEM_COLS as C, userDisplayLabel as $, renderDisplayTemplate as L } from "../../pipeline/relations.js";
7
+ import { collectionMetaKey as O, useCollectionBody as _ } from "../collection-meta.js";
8
+ import { choiceLabelsFrom as A } from "./describe-conditions.js";
9
+ import { recordCountFilter as E } from "./record-count.js";
9
10
  const v = {
10
11
  overview: (e) => ["layout-editor", "overview", e],
11
12
  fields: (e) => ["layout-editor", "fields", e],
12
- meta: (e) => L(e),
13
+ meta: (e) => O(e),
13
14
  roles: () => ["layout-editor", "roles"]
14
15
  };
15
- function j(e, r) {
16
+ function j(e, n) {
16
17
  if (!e || typeof e != "object") return null;
17
- if (r in e) return e;
18
+ if (n in e) return e;
18
19
  const t = e.data;
19
20
  return t && typeof t == "object" ? t : null;
20
21
  }
21
- function U(e) {
22
- const r = p();
22
+ function z(e) {
23
+ const n = p();
23
24
  return h({
24
25
  queryKey: v.overview(e),
25
26
  queryFn: async () => {
26
- const t = await r.request(d("/collection-layouts/overview", { collection: e })), n = j(t, "rows");
27
- return { rows: (n == null ? void 0 : n.rows) ?? [], warning: (n == null ? void 0 : n.warning) ?? null };
27
+ const t = await n.request(m("/collection-layouts/overview", { collection: e })), r = j(t, "rows");
28
+ return { rows: (r == null ? void 0 : r.rows) ?? [], warning: (r == null ? void 0 : r.warning) ?? null };
28
29
  },
29
30
  staleTime: 15e3
30
31
  });
31
32
  }
32
- function x(e) {
33
- const r = p();
33
+ function B(e) {
34
+ const n = p();
34
35
  return h({
35
36
  queryKey: v.fields(e),
36
- queryFn: () => r.request(d(`/field-config/${e}`)).then((t) => t.data ?? []),
37
+ queryFn: () => n.request(m(`/field-config/${e}`)).then((t) => t.data ?? []),
37
38
  staleTime: 6e4
38
39
  });
39
40
  }
40
- function z(e, r) {
41
- const t = F(e, {
42
- enabled: r,
43
- select: (n) => typeof (n == null ? void 0 : n.display_template) == "string" ? n.display_template : null
41
+ function V(e, n) {
42
+ const t = _(e, {
43
+ enabled: n,
44
+ select: (r) => typeof (r == null ? void 0 : r.display_template) == "string" ? r.display_template : null
44
45
  });
45
46
  return t.isError ? { ...t, data: null } : t;
46
47
  }
47
- function B(e) {
48
- const r = p();
48
+ function Y(e) {
49
+ const n = p();
49
50
  return h({
50
51
  queryKey: v.roles(),
51
- queryFn: () => r.request(d("/roles")).then((t) => (t.data ?? []).map((n) => ({ id: String(n.id), name: String(n.name) }))),
52
+ queryFn: () => n.request(m("/roles")).then((t) => (t.data ?? []).map((r) => ({ id: String(r.id), name: String(r.name) }))),
52
53
  enabled: e,
53
54
  staleTime: 5 * 6e4
54
55
  });
55
56
  }
56
- function V(e) {
57
- const r = _();
58
- return S(
57
+ function G(e) {
58
+ const n = T();
59
+ return K(
59
60
  (t) => {
60
- const n = t != null && t.lazy ? "none" : "active";
61
+ const r = t != null && t.lazy ? "none" : "active";
61
62
  for (const s of [
62
63
  v.overview(e),
63
64
  ["layout-editor", "health", e],
64
65
  ["collection-layouts", e],
65
66
  ["active-layout", e]
66
67
  ])
67
- r.invalidateQueries({ queryKey: s, refetchType: n });
68
+ n.invalidateQueries({ queryKey: s, refetchType: r });
68
69
  },
69
- [r, e]
70
+ [n, e]
70
71
  );
71
72
  }
72
- function Y(e, r) {
73
- var i, q;
74
- const t = e, n = (t == null ? void 0 : t.status) ?? ((i = t == null ? void 0 : t.response) == null ? void 0 : i.status) ?? null, s = ((q = t == null ? void 0 : t.response) == null ? void 0 : q.data) ?? (t == null ? void 0 : t.response), f = typeof (s == null ? void 0 : s.error) == "string" && s.error || typeof (s == null ? void 0 : s.message) == "string" && s.message || r, o = Array.isArray(s == null ? void 0 : s.references) ? s.references.filter((m) => m && typeof m.label == "string") : [];
75
- return { status: n, message: f, references: o };
73
+ function H(e, n) {
74
+ var a, q;
75
+ const t = e, r = (t == null ? void 0 : t.status) ?? ((a = t == null ? void 0 : t.response) == null ? void 0 : a.status) ?? null, s = ((q = t == null ? void 0 : t.response) == null ? void 0 : q.data) ?? (t == null ? void 0 : t.response), f = typeof (s == null ? void 0 : s.error) == "string" && s.error || typeof (s == null ? void 0 : s.message) == "string" && s.message || n, l = Array.isArray(s == null ? void 0 : s.references) ? s.references.filter((d) => d && typeof d.label == "string") : [];
76
+ return { status: r, message: w(f, n, r), references: l };
76
77
  }
77
- function G(e, r, t, n = !0) {
78
- const s = p(), { userId: f } = T(), o = r ? A(r, t) : null;
78
+ function P(e, n, t, r = !0) {
79
+ const s = p(), { userId: f } = S(), l = n ? E(n, t) : null;
79
80
  return h({
80
- queryKey: ["layout-editor", "record-count", f, e, o],
81
+ queryKey: ["layout-editor", "record-count", f, e, l],
81
82
  queryFn: () => s.request(
82
- d(`/items/${e}`, {
83
+ m(`/items/${e}`, {
83
84
  limit: 1,
84
- ...o && Object.keys(o).length ? { filter: JSON.stringify(o) } : {}
85
+ ...l && Object.keys(l).length ? { filter: JSON.stringify(l) } : {}
85
86
  })
86
- ).then((i) => typeof (i == null ? void 0 : i.total) == "number" ? i.total : null),
87
- enabled: n && !!r && o != null,
87
+ ).then((a) => typeof (a == null ? void 0 : a.total) == "number" ? a.total : null),
88
+ enabled: r && !!n && l != null,
88
89
  staleTime: 6e4,
89
90
  retry: !1
90
91
  });
91
92
  }
92
- function H(e, r, t) {
93
- const n = g(() => {
93
+ function W(e, n, t) {
94
+ const r = g(() => {
94
95
  const s = [];
95
96
  for (const f of t)
96
- for (const o of f.reason.rules ?? [])
97
- (o.op === "eq" || o.op === "neq") && s.push({ field: o.field, value: o.value });
97
+ for (const l of f.reason.rules ?? [])
98
+ (l.op === "eq" || l.op === "neq") && s.push({ field: l.field, value: l.value });
98
99
  return s;
99
100
  }, [t]);
100
- return E(e, r, n);
101
+ return N(e, n, r);
101
102
  }
102
- function E(e, r, t) {
103
- const n = p(), s = _(), { data: f = [] } = F(e, {
104
- select: (l) => Array.isArray(l == null ? void 0 : l.relations) ? l.relations : []
105
- }), o = g(() => O(r), [r]), i = g(() => {
106
- const l = /* @__PURE__ */ new Map();
103
+ function N(e, n, t) {
104
+ const r = p(), s = T(), { data: f = [] } = _(e, {
105
+ select: (o) => Array.isArray(o == null ? void 0 : o.relations) ? o.relations : []
106
+ }), l = g(() => A(n), [n]), a = g(() => {
107
+ const o = /* @__PURE__ */ new Map();
107
108
  for (const u of t) {
108
- if (u.value == null || u.value === "" || o[u.field] || typeof u.value == "object" || typeof u.value == "string" && u.value.includes("{{")) continue;
109
- const a = f.find(
109
+ if (u.value == null || u.value === "" || l[u.field] || typeof u.value == "object" || typeof u.value == "string" && u.value.includes("{{")) continue;
110
+ const i = f.find(
110
111
  (c) => c.many_collection === e && c.many_field === u.field && c.junction_field == null && !!c.one_collection
111
112
  );
112
- if (!(a != null && a.one_collection)) continue;
113
+ if (!(i != null && i.one_collection)) continue;
113
114
  const y = String(u.value);
114
- l.set(`${u.field}:${y}`, { field: u.field, value: y, related: a.one_collection });
115
+ o.set(`${u.field}:${y}`, { field: u.field, value: y, related: i.one_collection });
115
116
  }
116
- return [...l.values()];
117
- }, [t, f, o, e]), q = K({
118
- queries: i.map((l) => ({
119
- queryKey: ["layout-editor", "rule-label", l.related, l.value],
117
+ return [...o.values()];
118
+ }, [t, f, l, e]), q = F({
119
+ queries: a.map((o) => ({
120
+ queryKey: ["layout-editor", "rule-label", o.related, o.value],
120
121
  queryFn: async () => {
121
- const u = w.has(l.related), a = await n.request(
122
- u ? d(`/users/${l.value}`) : d(`/items/${l.related}/${l.value}`, { fields: "*" })
122
+ const u = C.has(o.related), i = await r.request(
123
+ u ? m(`/users/${o.value}`) : m(`/items/${o.related}/${o.value}`, { fields: "*" })
123
124
  ).then((c) => c.data);
124
- if (!a) return null;
125
- if (u) return C(a);
125
+ if (!i) return null;
126
+ if (u) return $(i);
126
127
  const y = await s.fetchQuery({
127
- queryKey: v.meta(l.related),
128
- queryFn: () => n.request(
129
- d(`/collections/${l.related}`)
128
+ queryKey: v.meta(o.related),
129
+ queryFn: () => r.request(
130
+ m(`/collections/${o.related}`)
130
131
  ).then((c) => c.data),
131
132
  staleTime: 5 * 6e4
132
133
  });
133
- return $((y == null ? void 0 : y.display_template) ?? null, a) || null;
134
+ return L((y == null ? void 0 : y.display_template) ?? null, i) || null;
134
135
  },
135
136
  staleTime: 30 * 6e4,
136
137
  retry: !1
137
138
  }))
138
- }), m = JSON.stringify(q.map((l) => l.data ?? null));
139
+ }), d = JSON.stringify(q.map((o) => o.data ?? null));
139
140
  return g(() => {
140
- const l = JSON.parse(m), u = { ...o };
141
- return i.forEach((a, y) => {
142
- const c = l[y];
143
- c && (u[a.field] = { ...u[a.field] ?? {}, [a.value]: c });
141
+ const o = JSON.parse(d), u = { ...l };
142
+ return a.forEach((i, y) => {
143
+ const c = o[y];
144
+ c && (u[i.field] = { ...u[i.field] ?? {}, [i.value]: c });
144
145
  }), u;
145
- }, [o, i, m]);
146
+ }, [l, a, d]);
146
147
  }
147
148
  export {
148
- Y as apiFailure,
149
+ H as apiFailure,
149
150
  v as overviewKeys,
150
- G as useApproxRecordCount,
151
- z as useDisplayTemplate,
152
- V as useInvalidateLayouts,
153
- U as useLayoutOverview,
154
- x as useOverviewFields,
155
- B as useRoleNames,
156
- H as useRuleChoiceLabels,
157
- E as useValueLabels
151
+ P as useApproxRecordCount,
152
+ V as useDisplayTemplate,
153
+ G as useInvalidateLayouts,
154
+ z as useLayoutOverview,
155
+ B as useOverviewFields,
156
+ Y as useRoleNames,
157
+ W as useRuleChoiceLabels,
158
+ N as useValueLabels
158
159
  };