@nivaro/react 0.3.46 → 0.3.48
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/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +248 -16
- package/dist/index.js +679 -659
- package/dist/shared/components/CollectionBrowserView.js +813 -826
- package/dist/shared/components/ErrorNotice.js +169 -0
- package/dist/shared/components/ErrorSurface.js +23 -17
- package/dist/shared/components/ListLoadError.js +8 -29
- package/dist/shared/components/LoadErrorNote.js +38 -21
- package/dist/shared/components/QueryErrorState.js +8 -11
- package/dist/shared/components/ReportView.js +1320 -1291
- package/dist/shared/components/chat/ChannelArchive.js +60 -60
- package/dist/shared/components/chat/ChannelExtras.js +74 -74
- package/dist/shared/components/chat/ChatPanel.js +368 -367
- package/dist/shared/components/command-center/PeekPanel.js +33 -32
- package/dist/shared/components/command-center/panels/BoardSettings.js +41 -40
- package/dist/shared/components/command-center/panels/PeoplePanel.js +32 -31
- package/dist/shared/components/help-videos/editor/ClipsPanel.js +49 -48
- package/dist/shared/components/help-videos/editor/PublishButton.js +37 -36
- package/dist/shared/components/help-videos/editor/StatsTab.js +45 -44
- package/dist/shared/components/help-videos/editor/VersionsTab.js +29 -28
- package/dist/shared/components/help-videos/library/AuthorRolesButton.js +19 -18
- package/dist/shared/components/help-videos/library/HelpVideoLibrary.js +132 -129
- package/dist/shared/components/help-videos/library/LearningPathsPanel.js +42 -41
- package/dist/shared/components/help-videos/settings/HouseStyleButton.js +21 -20
- package/dist/shared/components/help-videos/settings/RenderSettingsButton.js +22 -21
- package/dist/shared/components/import/DocumentAutofillButton.js +24 -20
- package/dist/shared/components/import/ImportFromFileButton.js +61 -60
- package/dist/shared/components/imports/ImportStalenessControl.js +20 -21
- package/dist/shared/components/imports/NewImportDialog.js +29 -28
- package/dist/shared/components/imports/RunDetailSheet.js +63 -63
- package/dist/shared/components/item-edit/FieldRow.js +329 -329
- package/dist/shared/components/item-edit/InlineTableField.js +898 -898
- package/dist/shared/components/item-edit/PersonalDefaultControl.js +57 -56
- package/dist/shared/components/item-edit/PlanGrid.js +220 -221
- package/dist/shared/components/item-edit/RecordGrantTools.js +49 -48
- package/dist/shared/components/item-edit/placement-behaviour.js +68 -67
- package/dist/shared/components/layout-editor/inspector/ColumnFit.js +24 -23
- package/dist/shared/components/layout-editor/inspector/PickerPreview.js +17 -16
- package/dist/shared/components/layout-editor/matrix/FieldStateMatrix.js +41 -41
- package/dist/shared/components/layout-editor/outputs/output-api.js +33 -31
- package/dist/shared/components/layout-editor/overview/overview-api.js +84 -83
- package/dist/shared/components/layout-editor/useLayoutDraft.js +47 -42
- package/dist/shared/components/monitoring/InactiveUserLinksView.js +10 -9
- package/dist/shared/components/panels/SlaClock.js +35 -36
- package/dist/shared/components/pipeline/PipelineEditorView.js +311 -312
- package/dist/shared/components/pipeline/TeamSuggestions.js +31 -30
- package/dist/shared/components/profile/AgentsPanel.js +73 -72
- package/dist/shared/components/profile/MailSuppressedPill.js +22 -21
- package/dist/shared/components/support/SupportRequestDialog.js +85 -81
- package/dist/shared/components/support/SupportView.js +94 -87
- package/dist/shared/lib/autofill-poll.js +21 -18
- package/dist/shared/lib/error-actions.js +85 -0
- package/dist/shared/lib/error-message.js +223 -82
- package/dist/shared/lib/error-toast.js +71 -13
- package/dist/shared/lib/safe-error.js +136 -38
- 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 {
|
|
6
|
-
import { cn as
|
|
7
|
-
import { Skeleton as
|
|
8
|
-
import { targetOfKey as
|
|
9
|
-
import { resetPlacementOps as
|
|
10
|
-
import { useCollectionMeta as
|
|
11
|
-
import { overridePlacementOps as
|
|
12
|
-
import { LoadError as
|
|
13
|
-
import { useCollectionPipelines as
|
|
14
|
-
import { useCellMenu as
|
|
15
|
-
import { useSaveRequirements as
|
|
16
|
-
import { CELL_KINDS as z, stateCell as K, movesFrom as
|
|
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
|
|
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 === _ &&
|
|
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
|
|
35
|
-
const w =
|
|
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) => !
|
|
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
|
|
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 } =
|
|
55
|
+
const { data: g } = se(f), {
|
|
56
56
|
data: n = [],
|
|
57
57
|
isLoading: w,
|
|
58
58
|
isError: C,
|
|
59
59
|
refetch: b
|
|
60
|
-
} =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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:
|
|
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(
|
|
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(
|
|
156
|
-
|
|
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:
|
|
165
|
+
/* @__PURE__ */ r("th", { className: fe, children: "Field" }),
|
|
166
166
|
/* @__PURE__ */ r(
|
|
167
167
|
"th",
|
|
168
168
|
{
|
|
169
|
-
className:
|
|
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:
|
|
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
|
-
|
|
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:
|
|
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(
|
|
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
|
-
|
|
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(
|
|
224
|
+
onAction: () => t.source === "inherited" ? p(ie(o, a, t.row), {
|
|
225
225
|
label: `Override ${d} on this form`
|
|
226
|
-
}) : p(
|
|
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
|
|
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:
|
|
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 :
|
|
301
|
+
return typeof a == "string" ? X(a) : ee(o, "Something went wrong");
|
|
302
302
|
}
|
|
303
303
|
export {
|
|
304
|
-
|
|
305
|
-
|
|
304
|
+
Ze as FieldStateMatrix,
|
|
305
|
+
ke as matrixZones
|
|
306
306
|
};
|
|
@@ -1,56 +1,58 @@
|
|
|
1
|
-
var
|
|
2
|
-
var p = (e, t, a) => t in e ?
|
|
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
|
-
|
|
5
|
-
|
|
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
|
-
|
|
8
|
-
a
|
|
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
|
|
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
|
|
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
|
|
23
|
-
return { blob: await o.blob(), filename:
|
|
24
|
+
if (!o.ok) throw await s(o);
|
|
25
|
+
return { blob: await o.blob(), filename: c(o, a) };
|
|
24
26
|
}
|
|
25
|
-
async function
|
|
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
|
|
33
|
-
return { blob: await n.blob(), filename:
|
|
34
|
+
if (!n.ok) throw await s(n);
|
|
35
|
+
return { blob: await n.blob(), filename: c(n, o) };
|
|
34
36
|
}
|
|
35
|
-
const
|
|
36
|
-
async function
|
|
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
|
|
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
|
|
50
|
+
body: JSON.stringify({ file: await h(t) })
|
|
49
51
|
});
|
|
50
|
-
if (!a.ok) throw await
|
|
52
|
+
if (!a.ok) throw await s(a);
|
|
51
53
|
return (await a.json()).data.rows;
|
|
52
54
|
}
|
|
53
|
-
const
|
|
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
|
|
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 ??
|
|
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
|
|
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
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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
|
|
2
|
-
import { useCallback as
|
|
3
|
-
import { useNivaroClient as p, useItemEditAuth as
|
|
4
|
-
import { get as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
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) =>
|
|
13
|
+
meta: (e) => O(e),
|
|
13
14
|
roles: () => ["layout-editor", "roles"]
|
|
14
15
|
};
|
|
15
|
-
function j(e,
|
|
16
|
+
function j(e, n) {
|
|
16
17
|
if (!e || typeof e != "object") return null;
|
|
17
|
-
if (
|
|
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
|
|
22
|
-
const
|
|
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
|
|
27
|
-
return { rows: (
|
|
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
|
|
33
|
-
const
|
|
33
|
+
function B(e) {
|
|
34
|
+
const n = p();
|
|
34
35
|
return h({
|
|
35
36
|
queryKey: v.fields(e),
|
|
36
|
-
queryFn: () =>
|
|
37
|
+
queryFn: () => n.request(m(`/field-config/${e}`)).then((t) => t.data ?? []),
|
|
37
38
|
staleTime: 6e4
|
|
38
39
|
});
|
|
39
40
|
}
|
|
40
|
-
function
|
|
41
|
-
const t =
|
|
42
|
-
enabled:
|
|
43
|
-
select: (
|
|
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
|
|
48
|
-
const
|
|
48
|
+
function Y(e) {
|
|
49
|
+
const n = p();
|
|
49
50
|
return h({
|
|
50
51
|
queryKey: v.roles(),
|
|
51
|
-
queryFn: () =>
|
|
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
|
|
57
|
-
const
|
|
58
|
-
return
|
|
57
|
+
function G(e) {
|
|
58
|
+
const n = T();
|
|
59
|
+
return K(
|
|
59
60
|
(t) => {
|
|
60
|
-
const
|
|
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
|
-
|
|
68
|
+
n.invalidateQueries({ queryKey: s, refetchType: r });
|
|
68
69
|
},
|
|
69
|
-
[
|
|
70
|
+
[n, e]
|
|
70
71
|
);
|
|
71
72
|
}
|
|
72
|
-
function
|
|
73
|
-
var
|
|
74
|
-
const t = e,
|
|
75
|
-
return { status:
|
|
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
|
|
78
|
-
const s = p(), { userId: f } =
|
|
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,
|
|
81
|
+
queryKey: ["layout-editor", "record-count", f, e, l],
|
|
81
82
|
queryFn: () => s.request(
|
|
82
|
-
|
|
83
|
+
m(`/items/${e}`, {
|
|
83
84
|
limit: 1,
|
|
84
|
-
...
|
|
85
|
+
...l && Object.keys(l).length ? { filter: JSON.stringify(l) } : {}
|
|
85
86
|
})
|
|
86
|
-
).then((
|
|
87
|
-
enabled:
|
|
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
|
|
93
|
-
const
|
|
93
|
+
function W(e, n, t) {
|
|
94
|
+
const r = g(() => {
|
|
94
95
|
const s = [];
|
|
95
96
|
for (const f of t)
|
|
96
|
-
for (const
|
|
97
|
-
(
|
|
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
|
|
101
|
+
return N(e, n, r);
|
|
101
102
|
}
|
|
102
|
-
function
|
|
103
|
-
const
|
|
104
|
-
select: (
|
|
105
|
-
}),
|
|
106
|
-
const
|
|
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 === "" ||
|
|
109
|
-
const
|
|
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 (!(
|
|
113
|
+
if (!(i != null && i.one_collection)) continue;
|
|
113
114
|
const y = String(u.value);
|
|
114
|
-
|
|
115
|
+
o.set(`${u.field}:${y}`, { field: u.field, value: y, related: i.one_collection });
|
|
115
116
|
}
|
|
116
|
-
return [...
|
|
117
|
-
}, [t, f,
|
|
118
|
-
queries:
|
|
119
|
-
queryKey: ["layout-editor", "rule-label",
|
|
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 =
|
|
122
|
-
u ?
|
|
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 (!
|
|
125
|
-
if (u) return
|
|
125
|
+
if (!i) return null;
|
|
126
|
+
if (u) return $(i);
|
|
126
127
|
const y = await s.fetchQuery({
|
|
127
|
-
queryKey: v.meta(
|
|
128
|
-
queryFn: () =>
|
|
129
|
-
|
|
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
|
|
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
|
-
}),
|
|
139
|
+
}), d = JSON.stringify(q.map((o) => o.data ?? null));
|
|
139
140
|
return g(() => {
|
|
140
|
-
const
|
|
141
|
-
return
|
|
142
|
-
const c =
|
|
143
|
-
c && (u[
|
|
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
|
-
}, [
|
|
146
|
+
}, [l, a, d]);
|
|
146
147
|
}
|
|
147
148
|
export {
|
|
148
|
-
|
|
149
|
+
H as apiFailure,
|
|
149
150
|
v as overviewKeys,
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
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
|
};
|