@nivaro/react 0.3.99 → 0.3.101
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/useFormSchema.js +82 -85
- package/dist/hooks/useSessionRecorder.js +206 -175
- package/dist/index.d.ts +84 -16
- package/dist/index.js +627 -622
- package/dist/lib/commands.js +15 -11
- package/dist/shared/components/ActivityEntry.js +5 -5
- package/dist/shared/components/CollectionBrowserView.js +516 -503
- package/dist/shared/components/ItemEditForm.js +3471 -3465
- package/dist/shared/components/JobsTray.js +76 -61
- package/dist/shared/components/MyWorkView.js +133 -126
- package/dist/shared/components/NotificationBell.js +322 -289
- package/dist/shared/components/RecordCompare.js +38 -40
- package/dist/shared/components/RecordReadView.js +119 -119
- package/dist/shared/components/TipLayer.js +56 -41
- package/dist/shared/components/cbv/FoundElsewhere.js +61 -0
- package/dist/shared/components/integrations/console/SignalCard.js +40 -40
- package/dist/shared/components/integrations/console/drill/SubmissionDrill.js +95 -73
- package/dist/shared/components/integrations/console/drill/status.js +23 -18
- package/dist/shared/components/item-edit/InlineGridField.js +45 -45
- package/dist/shared/components/item-edit/InlineTableField.js +750 -749
- package/dist/shared/components/item-edit/QuickPickerDialog.js +44 -44
- package/dist/shared/components/item-edit/RawEditSheet.js +122 -114
- package/dist/shared/components/item-edit/RecordInsights.js +86 -86
- package/dist/shared/components/item-edit/RelationCombobox.js +454 -378
- package/dist/shared/components/item-edit/SummaryPanel.js +56 -48
- package/dist/shared/components/item-edit/header-path-preview.js +46 -34
- package/dist/shared/components/item-edit/related-missing.js +75 -19
- package/dist/shared/components/notifications/DeliveryChips.js +1 -2
- package/dist/shared/components/notifications/NotificationCenterView.js +249 -226
- package/dist/shared/components/panels/AccessDeniedPanel.js +31 -28
- package/dist/shared/components/panels/BackgroundMove.js +242 -0
- package/dist/shared/components/panels/MoveAdvisory.js +204 -0
- package/dist/shared/components/panels/PipelinePanel.js +1459 -1220
- package/dist/shared/components/panels/RecordIntegrityBanner.js +113 -112
- package/dist/shared/components/profile/ActivityFeedCard.js +322 -0
- package/dist/shared/components/profile/DayTimeline.js +145 -140
- package/dist/shared/components/profile/PersonAccess.js +679 -383
- package/dist/shared/components/profile/PersonActivity.js +404 -427
- package/dist/shared/components/profile/PersonDidPanel.js +248 -134
- package/dist/shared/components/profile/PersonProfile.js +33 -32
- package/dist/shared/components/profile/journey-view.js +166 -0
- package/dist/shared/lib/activity-sentence.js +319 -236
- package/dist/shared/lib/commands.js +18 -14
- package/dist/shared/lib/error-hints.js +1 -1
- package/dist/shared/lib/job-failure-text.js +12 -0
- package/dist/shared/lib/jobs-tray.js +60 -41
- package/dist/shared/lib/move-failure.js +19 -0
- package/dist/shared/lib/obligation-banner.js +22 -21
- package/dist/shared/lib/partner-failure.js +83 -0
- package/dist/shared/lib/prefetch.js +73 -73
- package/dist/shared/lib/replay-checkout.js +18 -13
- package/dist/shared/lib/replay-context.js +90 -77
- package/dist/shared/lib/replay-idle.js +21 -0
- package/dist/shared/lib/replay-socket.js +21 -17
- package/dist/shared/lib/rum.js +56 -51
- package/dist/shared/lib/safe-error.js +17 -13
- package/dist/shared/lib/stale-chunk.js +69 -26
- package/dist/shared/lib/system-collections.js +20 -0
- package/package.json +1 -1
|
@@ -24,7 +24,7 @@ function je({
|
|
|
24
24
|
maxValues: c
|
|
25
25
|
}) {
|
|
26
26
|
var K, T;
|
|
27
|
-
const r = U(),
|
|
27
|
+
const r = U(), u = e.many_field ?? "", f = e.junction_field ?? (() => {
|
|
28
28
|
const t = a.find(
|
|
29
29
|
(s) => s.many_collection === e.many_collection && s.id !== e.id
|
|
30
30
|
);
|
|
@@ -41,23 +41,23 @@ function je({
|
|
|
41
41
|
}), o = g ?? ((T = b == null ? void 0 : b.find(
|
|
42
42
|
(t) => t.many_collection === e.many_collection && t.many_field === f && !!t.one_collection
|
|
43
43
|
)) == null ? void 0 : T.one_collection) ?? null, { data: d = [] } = $({
|
|
44
|
-
queryKey: ["m2m-items", e.many_collection,
|
|
44
|
+
queryKey: ["m2m-items", e.many_collection, u, n],
|
|
45
45
|
queryFn: () => r.request(
|
|
46
46
|
L(`/items/${e.many_collection}`, {
|
|
47
|
-
filter: JSON.stringify({ [
|
|
47
|
+
filter: JSON.stringify({ [u]: { _eq: n } }),
|
|
48
48
|
limit: 200,
|
|
49
49
|
fields: `id,${f}`
|
|
50
50
|
})
|
|
51
51
|
).then((t) => t.data ?? []),
|
|
52
52
|
staleTime: 3e4,
|
|
53
53
|
enabled: !!n && n !== "new"
|
|
54
|
-
}),
|
|
54
|
+
}), m = o ? void 0 : [...a, ...b ?? []].find(
|
|
55
55
|
(t) => t.many_collection === e.many_collection && t.many_field === f && !!t.one_collection_field
|
|
56
|
-
), k = (
|
|
57
|
-
queryKey: ["summary-m2a-items", e.many_collection,
|
|
56
|
+
), k = (m == null ? void 0 : m.one_collection_field) ?? null, E = m ? $e(m) : null, { data: F = [] } = $({
|
|
57
|
+
queryKey: ["summary-m2a-items", e.many_collection, u, n, k],
|
|
58
58
|
queryFn: () => r.request(
|
|
59
59
|
L(`/items/${e.many_collection}`, {
|
|
60
|
-
filter: JSON.stringify({ [
|
|
60
|
+
filter: JSON.stringify({ [u]: { _eq: n } }),
|
|
61
61
|
limit: 200,
|
|
62
62
|
fields: `id,${f},${k}`
|
|
63
63
|
})
|
|
@@ -151,7 +151,15 @@ function de(e) {
|
|
|
151
151
|
}
|
|
152
152
|
function X({ collection: e, id: n }) {
|
|
153
153
|
const a = de(e);
|
|
154
|
-
return /* @__PURE__ */ i(
|
|
154
|
+
return /* @__PURE__ */ i(
|
|
155
|
+
se,
|
|
156
|
+
{
|
|
157
|
+
collection: e,
|
|
158
|
+
id: n,
|
|
159
|
+
displayTemplate: a ?? void 0,
|
|
160
|
+
explainMissing: !0
|
|
161
|
+
}
|
|
162
|
+
);
|
|
155
163
|
}
|
|
156
164
|
const Me = ["name", "title", "label", "subject", "description", "line_number"], Ce = ["amount", "total", "cost"], C = (e) => {
|
|
157
165
|
if (typeof e == "number") return Number.isFinite(e) ? e : null;
|
|
@@ -168,8 +176,8 @@ function ve(e) {
|
|
|
168
176
|
of: (l) => {
|
|
169
177
|
const c = n ? C(l[n]) : null;
|
|
170
178
|
if (c !== null) return c;
|
|
171
|
-
const r = C(l.price),
|
|
172
|
-
return r !== null &&
|
|
179
|
+
const r = C(l.price), u = C(l.quantity);
|
|
180
|
+
return r !== null && u !== null ? Math.round(r * u * 100) / 100 : null;
|
|
173
181
|
}
|
|
174
182
|
} : e.some((l) => C(l.quantity) !== null) ? { currency: !1, of: (l) => C(l.quantity) } : null;
|
|
175
183
|
}
|
|
@@ -205,10 +213,10 @@ const Ke = ["cifa", "item", "catalog_item", "product", "part", "material"], Ae =
|
|
|
205
213
|
function Pe(e, n, a) {
|
|
206
214
|
const l = e.filter(
|
|
207
215
|
(r) => r.many_collection === n && !!r.many_field && r.many_field !== a && !r.junction_field && !!r.one_collection && !Ae.has(r.one_collection)
|
|
208
|
-
), c = Ke.map((r) => l.find((
|
|
216
|
+
), c = Ke.map((r) => l.find((u) => u.many_field === r)).find(Boolean) ?? l[0];
|
|
209
217
|
return c != null && c.many_field && c.one_collection ? { field: c.many_field, collection: c.one_collection } : null;
|
|
210
218
|
}
|
|
211
|
-
function
|
|
219
|
+
function ue({
|
|
212
220
|
relatedCollection: e,
|
|
213
221
|
manyField: n,
|
|
214
222
|
parentId: a,
|
|
@@ -216,7 +224,7 @@ function me({
|
|
|
216
224
|
expanded: c
|
|
217
225
|
}) {
|
|
218
226
|
var K, T;
|
|
219
|
-
const r = U(),
|
|
227
|
+
const r = U(), u = ke(ce), f = l && Object.keys(l).length > 0 ? {
|
|
220
228
|
_and: [
|
|
221
229
|
{ [n]: { _eq: a } },
|
|
222
230
|
Object.fromEntries(
|
|
@@ -249,26 +257,26 @@ function me({
|
|
|
249
257
|
return ((s = t.data) == null ? void 0 : s.relations) ?? [];
|
|
250
258
|
}),
|
|
251
259
|
staleTime: 10 * 6e4
|
|
252
|
-
}), d = Pe(o, e, n),
|
|
260
|
+
}), d = Pe(o, e, n), m = Re(b), k = [...new Set(m.map((t) => t.split(".")[0]))], E = m.length ? JSON.stringify((p ?? []).map((t) => [t.id, ...k.map((s) => t[s] ?? null)])) : "", { data: F } = $({
|
|
253
261
|
queryKey: [
|
|
254
262
|
"o2m-summary-labels",
|
|
255
263
|
e,
|
|
256
264
|
n,
|
|
257
265
|
a,
|
|
258
266
|
l ? JSON.stringify(l) : "",
|
|
259
|
-
|
|
267
|
+
m.join(","),
|
|
260
268
|
E
|
|
261
269
|
],
|
|
262
270
|
queryFn: () => r.request(
|
|
263
271
|
L(`/items/${e}`, {
|
|
264
272
|
filter: JSON.stringify(f),
|
|
265
|
-
fields: ["id", ...
|
|
273
|
+
fields: ["id", ...m].join(","),
|
|
266
274
|
limit: H
|
|
267
275
|
})
|
|
268
276
|
).then((t) => t.data ?? []).catch(() => []),
|
|
269
|
-
enabled:
|
|
277
|
+
enabled: m.length > 0 && !!a && a !== "new" && ((p == null ? void 0 : p.length) ?? 0) > 0,
|
|
270
278
|
staleTime: 6e4
|
|
271
|
-
}), I = new Map((F ?? []).map((t) => [String(t.id), t])), O = `${e}.${n}`, w = (K =
|
|
279
|
+
}), I = new Map((F ?? []).map((t) => [String(t.id), t])), O = `${e}.${n}`, w = (K = u.deletes) == null ? void 0 : K.get(O), R = (((T = u.rows) == null ? void 0 : T.get(O)) ?? []).filter(
|
|
272
280
|
(t) => Oe(t, l)
|
|
273
281
|
), S = [
|
|
274
282
|
...(p ?? []).filter((t) => !(w != null && w.has(String(t.id)))),
|
|
@@ -300,7 +308,7 @@ function me({
|
|
|
300
308
|
className: "flex items-baseline justify-between gap-2 text-[11px] text-slate-500 dark:text-slate-400",
|
|
301
309
|
children: [
|
|
302
310
|
/* @__PURE__ */ i("span", { className: "truncate", children: Ee(
|
|
303
|
-
De(t, I.get(String(t.id)),
|
|
311
|
+
De(t, I.get(String(t.id)), m),
|
|
304
312
|
b ?? null
|
|
305
313
|
) ?? (d && t[d.field] != null && t[d.field] !== "" ? /* @__PURE__ */ i(X, { collection: d.collection, id: t[d.field] }) : `Row ${s + 1}`) }),
|
|
306
314
|
_ && _.of(t) !== null && /* @__PURE__ */ i("span", { className: "shrink-0 tabular-nums", children: (() => {
|
|
@@ -336,8 +344,8 @@ function Ie({
|
|
|
336
344
|
itemId: c,
|
|
337
345
|
staging: r
|
|
338
346
|
}) {
|
|
339
|
-
const
|
|
340
|
-
if (!f.has(
|
|
347
|
+
const u = e.interface ?? "", f = /* @__PURE__ */ new Set(["select-multiple-m2m", "files-m2m", "files", "relation-grouped"]);
|
|
348
|
+
if (!f.has(u) && c) {
|
|
341
349
|
const o = a.find(
|
|
342
350
|
(d) => !d.junction_field && (d.one_field === e.field || d.many_collection === e.field) && (d.one_collection === l || d.one_collection == null)
|
|
343
351
|
);
|
|
@@ -350,7 +358,7 @@ function Ie({
|
|
|
350
358
|
}
|
|
351
359
|
})();
|
|
352
360
|
return /* @__PURE__ */ i(
|
|
353
|
-
|
|
361
|
+
ue,
|
|
354
362
|
{
|
|
355
363
|
relatedCollection: o.many_collection,
|
|
356
364
|
manyField: o.many_field,
|
|
@@ -360,17 +368,17 @@ function Ie({
|
|
|
360
368
|
);
|
|
361
369
|
}
|
|
362
370
|
}
|
|
363
|
-
if (f.has(
|
|
371
|
+
if (f.has(u) && c) {
|
|
364
372
|
const o = a.find(
|
|
365
|
-
(
|
|
373
|
+
(m) => m.one_collection === l && (m.one_field === e.field || m.junction_field != null && m.many_collection === e.field)
|
|
366
374
|
), d = o ? o.junction_field ? o : (() => {
|
|
367
|
-
const
|
|
375
|
+
const m = a.find(
|
|
368
376
|
(k) => k.many_collection === o.many_collection && k.id !== o.id
|
|
369
377
|
);
|
|
370
|
-
return
|
|
378
|
+
return m ? { ...o, junction_field: m.many_field } : null;
|
|
371
379
|
})() : null;
|
|
372
380
|
if (d) {
|
|
373
|
-
const
|
|
381
|
+
const m = oe(e.options);
|
|
374
382
|
return /* @__PURE__ */ i(
|
|
375
383
|
je,
|
|
376
384
|
{
|
|
@@ -378,7 +386,7 @@ function Ie({
|
|
|
378
386
|
parentId: c,
|
|
379
387
|
allRelations: a,
|
|
380
388
|
staging: r,
|
|
381
|
-
maxValues:
|
|
389
|
+
maxValues: m == null ? void 0 : m.max_values
|
|
382
390
|
}
|
|
383
391
|
);
|
|
384
392
|
}
|
|
@@ -387,8 +395,8 @@ function Ie({
|
|
|
387
395
|
if (p && e.type === "boolean")
|
|
388
396
|
return /* @__PURE__ */ i("span", { className: "text-slate-700 dark:text-slate-200", children: "No" });
|
|
389
397
|
if (p) return /* @__PURE__ */ i("span", { className: "text-slate-400 dark:text-slate-500", children: "—" });
|
|
390
|
-
if (
|
|
391
|
-
const o = He(n,
|
|
398
|
+
if (u === "extension-editorjs" || u === "input-rich-text-html" || u === "rich_text" || u === "wysiwyg" || typeof n == "string") {
|
|
399
|
+
const o = He(n, u);
|
|
392
400
|
if (o !== null)
|
|
393
401
|
return /* @__PURE__ */ i("span", { className: "truncate text-slate-700 dark:text-slate-200", title: o, children: o || "—" });
|
|
394
402
|
}
|
|
@@ -453,7 +461,7 @@ function ae(e, n) {
|
|
|
453
461
|
enabled: c,
|
|
454
462
|
staleTime: 10 * 6e4,
|
|
455
463
|
retry: !1
|
|
456
|
-
}), { data:
|
|
464
|
+
}), { data: u } = $({
|
|
457
465
|
queryKey: ["rrv-related", e, String(n)],
|
|
458
466
|
queryFn: () => l(e, n).catch(() => null),
|
|
459
467
|
enabled: c && !!r,
|
|
@@ -461,10 +469,10 @@ function ae(e, n) {
|
|
|
461
469
|
retry: !1
|
|
462
470
|
});
|
|
463
471
|
if (!c) return null;
|
|
464
|
-
if (!
|
|
465
|
-
const f = re(r == null ? void 0 : r.display_template,
|
|
472
|
+
if (!u) return "a linked record";
|
|
473
|
+
const f = re(r == null ? void 0 : r.display_template, u).trim();
|
|
466
474
|
if (f) return f;
|
|
467
|
-
for (const p of ["name", "title", "label", "number", "email"]) if (
|
|
475
|
+
for (const p of ["name", "title", "label", "number", "email"]) if (u[p]) return String(u[p]);
|
|
468
476
|
return "a linked record";
|
|
469
477
|
}
|
|
470
478
|
function We({
|
|
@@ -474,13 +482,13 @@ function We({
|
|
|
474
482
|
detail: l,
|
|
475
483
|
relations: c,
|
|
476
484
|
collection: r,
|
|
477
|
-
onRevert:
|
|
485
|
+
onRevert: u
|
|
478
486
|
}) {
|
|
479
487
|
var o;
|
|
480
488
|
const f = ((o = c.find(
|
|
481
489
|
(d) => d.many_collection === r && d.many_field === e.field && !!d.one_collection
|
|
482
490
|
)) == null ? void 0 : o.one_collection) ?? null, p = ae(f, n), g = ae(f, a), b = l ? `Unsaved — ${l}` : `Unsaved — was ${p ?? le(n)} → now ${g ?? le(a)}`;
|
|
483
|
-
return
|
|
491
|
+
return u ? (
|
|
484
492
|
// biome-ignore lint/a11y/useSemanticElements: nested inside the row's <button> — a real <button> is invalid there
|
|
485
493
|
/* @__PURE__ */ i(
|
|
486
494
|
"span",
|
|
@@ -491,10 +499,10 @@ function We({
|
|
|
491
499
|
"data-tip": `${b} · click to revert`,
|
|
492
500
|
"aria-label": "Revert this change",
|
|
493
501
|
onClick: (d) => {
|
|
494
|
-
d.stopPropagation(),
|
|
502
|
+
d.stopPropagation(), u();
|
|
495
503
|
},
|
|
496
504
|
onKeyDown: (d) => {
|
|
497
|
-
(d.key === "Enter" || d.key === " ") && (d.preventDefault(), d.stopPropagation(),
|
|
505
|
+
(d.key === "Enter" || d.key === " ") && (d.preventDefault(), d.stopPropagation(), u());
|
|
498
506
|
},
|
|
499
507
|
className: "group/dot inline-flex h-4 w-4 shrink-0 cursor-pointer items-center justify-center rounded-full hover:bg-amber-100 dark:hover:bg-amber-500/20",
|
|
500
508
|
children: /* @__PURE__ */ i("span", { className: "h-1.5 w-1.5 rounded-full bg-amber-400 ring-2 ring-amber-100 group-hover/dot:ring-amber-200 dark:ring-amber-500/30" })
|
|
@@ -516,14 +524,14 @@ function it({
|
|
|
516
524
|
sectionGroups: l,
|
|
517
525
|
draft: c,
|
|
518
526
|
relations: r,
|
|
519
|
-
collection:
|
|
527
|
+
collection: u,
|
|
520
528
|
itemId: f,
|
|
521
529
|
staging: p,
|
|
522
530
|
errors: g,
|
|
523
531
|
staleFields: b,
|
|
524
532
|
aliasEmptiness: o,
|
|
525
533
|
layoutFields: d,
|
|
526
|
-
changedFields:
|
|
534
|
+
changedFields: m,
|
|
527
535
|
onRevertChange: k,
|
|
528
536
|
onFieldClick: E,
|
|
529
537
|
stagedO2MRows: F,
|
|
@@ -536,7 +544,7 @@ function it({
|
|
|
536
544
|
const s = (t.key === "__general__" ? [...a, ...l.flatMap((x) => n[x.key] ?? [])] : n[t.key] ?? []).filter((x) => !x.hidden && !qe.has(x.field) && !Te.has(x.field));
|
|
537
545
|
return { step: t, fields: s };
|
|
538
546
|
}).filter((t) => t.fields.length > 0), K = new Set(q.flatMap((t) => t.fields.map((s) => s.field))), T = f && f !== "new" ? r.filter(
|
|
539
|
-
(t) => !t.junction_field && t.many_field && t.many_collection && (t.one_collection ===
|
|
547
|
+
(t) => !t.junction_field && t.many_field && t.many_collection && (t.one_collection === u || t.one_collection == null) && t.one_field != null && !K.has(t.one_field) && // Off-layout aliases stay out — the sidebar summarizes THIS layout.
|
|
540
548
|
(!d || d.has(t.one_field))
|
|
541
549
|
) : [];
|
|
542
550
|
return q.length === 0 && T.length === 0 ? null : /* @__PURE__ */ i(ce.Provider, { value: { rows: F, deletes: I }, children: /* @__PURE__ */ h("div", { className: "overflow-hidden bg-white dark:bg-card", children: [
|
|
@@ -553,7 +561,7 @@ function it({
|
|
|
553
561
|
}
|
|
554
562
|
),
|
|
555
563
|
s.map((y, P) => {
|
|
556
|
-
const N = c[y.field], M = y.label ?? ee(y.field), A = !!(g != null && g[y.field]), J = o == null ? void 0 : o[y.field],
|
|
564
|
+
const N = c[y.field], M = y.label ?? ee(y.field), A = !!(g != null && g[y.field]), J = o == null ? void 0 : o[y.field], me = J !== void 0 ? J === !0 : N == null || typeof N == "string" && N.trim() === "" || Array.isArray(N) && N.length === 0, fe = J === null, W = !!y.required && me && !A && !fe, Y = (b == null ? void 0 : b.has(y.field)) ?? !1;
|
|
557
565
|
return /* @__PURE__ */ h(
|
|
558
566
|
"div",
|
|
559
567
|
{
|
|
@@ -582,15 +590,15 @@ function it({
|
|
|
582
590
|
),
|
|
583
591
|
children: [
|
|
584
592
|
/* @__PURE__ */ i("span", { className: "truncate", children: M }),
|
|
585
|
-
(
|
|
593
|
+
(m == null ? void 0 : m[y.field]) && /* @__PURE__ */ i(
|
|
586
594
|
We,
|
|
587
595
|
{
|
|
588
596
|
field: y,
|
|
589
|
-
from:
|
|
590
|
-
detail:
|
|
597
|
+
from: m[y.field].from,
|
|
598
|
+
detail: m[y.field].detail,
|
|
591
599
|
to: N,
|
|
592
600
|
relations: r,
|
|
593
|
-
collection:
|
|
601
|
+
collection: u,
|
|
594
602
|
onRevert: k ? () => k(y.field) : void 0
|
|
595
603
|
}
|
|
596
604
|
),
|
|
@@ -619,7 +627,7 @@ function it({
|
|
|
619
627
|
field: y,
|
|
620
628
|
val: N,
|
|
621
629
|
relations: r,
|
|
622
|
-
collection:
|
|
630
|
+
collection: u,
|
|
623
631
|
itemId: f,
|
|
624
632
|
staging: p
|
|
625
633
|
}
|
|
@@ -704,7 +712,7 @@ function it({
|
|
|
704
712
|
ee(t.one_field ?? t.many_collection ?? "")
|
|
705
713
|
] }),
|
|
706
714
|
/* @__PURE__ */ i("span", { className: "mt-0.5 text-[12px]", children: /* @__PURE__ */ i(
|
|
707
|
-
|
|
715
|
+
ue,
|
|
708
716
|
{
|
|
709
717
|
relatedCollection: t.many_collection ?? "",
|
|
710
718
|
manyField: t.many_field,
|
|
@@ -1,52 +1,64 @@
|
|
|
1
|
-
import { useQueries as
|
|
2
|
-
import { useMemo as
|
|
3
|
-
import { useNivaroClient as
|
|
4
|
-
import { get as
|
|
5
|
-
|
|
1
|
+
import { useQueries as m } from "@tanstack/react-query";
|
|
2
|
+
import { useMemo as h } from "react";
|
|
3
|
+
import { useNivaroClient as w } from "../../context.js";
|
|
4
|
+
import { get as j } from "../../lib/commands.js";
|
|
5
|
+
const p = (e) => String((e != null && typeof e == "object" ? e.id : e) ?? "");
|
|
6
|
+
function _(e, c) {
|
|
7
|
+
let r = null;
|
|
8
|
+
for (const [i, d] of Object.entries(e)) {
|
|
9
|
+
const l = i.indexOf(".");
|
|
10
|
+
if (l <= 0 || i in c) continue;
|
|
11
|
+
const s = i.slice(0, l);
|
|
12
|
+
!(s in c) || p(e[s]) !== p(c[s]) || (r ?? (r = { ...c }), r[i] = d);
|
|
13
|
+
}
|
|
14
|
+
return r ?? c;
|
|
15
|
+
}
|
|
16
|
+
function y(e, c, r, i) {
|
|
6
17
|
const d = [];
|
|
7
|
-
for (const l of
|
|
8
|
-
const
|
|
9
|
-
if (
|
|
10
|
-
const [t,
|
|
11
|
-
if (
|
|
12
|
-
const
|
|
13
|
-
!
|
|
18
|
+
for (const l of e) {
|
|
19
|
+
const s = l.split(".");
|
|
20
|
+
if (s.length !== 2 || !s[0] || !s[1]) continue;
|
|
21
|
+
const [t, n] = s, o = c[t], a = o != null && typeof o == "object" ? o.id : o;
|
|
22
|
+
if (a == null || a === "") continue;
|
|
23
|
+
const u = r[t], f = u != null && typeof u == "object" ? u.id : u;
|
|
24
|
+
!i && String(f ?? "") === String(a) || d.push({ path: l, hop: t, rest: n, id: String(a) });
|
|
14
25
|
}
|
|
15
26
|
return d;
|
|
16
27
|
}
|
|
17
|
-
function
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
(
|
|
28
|
+
function b(e) {
|
|
29
|
+
const c = w(), r = y(e.paths, e.draft, e.saved, e.isNew).map((t) => {
|
|
30
|
+
const n = e.relations.find(
|
|
31
|
+
(o) => o.many_collection === e.collection && o.many_field === t.hop && !o.junction_field
|
|
21
32
|
);
|
|
22
|
-
return
|
|
23
|
-
}).filter((t) => !!t),
|
|
24
|
-
for (const t of
|
|
25
|
-
const
|
|
26
|
-
|
|
33
|
+
return n != null && n.one_collection ? { ...t, target: n.one_collection } : null;
|
|
34
|
+
}).filter((t) => !!t), i = /* @__PURE__ */ new Map();
|
|
35
|
+
for (const t of r) {
|
|
36
|
+
const n = `${t.target}:${t.id}`, o = i.get(n) ?? { target: t.target, id: t.id, fields: /* @__PURE__ */ new Set() };
|
|
37
|
+
o.fields.add(t.rest), i.set(n, o);
|
|
27
38
|
}
|
|
28
|
-
const d = [...
|
|
39
|
+
const d = [...i.values()], l = m({
|
|
29
40
|
queries: d.map((t) => ({
|
|
30
41
|
queryKey: ["header-path-preview", t.target, t.id, [...t.fields].sort().join(",")],
|
|
31
|
-
queryFn: () =>
|
|
32
|
-
|
|
42
|
+
queryFn: () => c.request(
|
|
43
|
+
j(`/items/${t.target}/${encodeURIComponent(t.id)}`, {
|
|
33
44
|
fields: [...t.fields].join(",")
|
|
34
45
|
})
|
|
35
|
-
).then((
|
|
46
|
+
).then((n) => n.data ?? null).catch(() => null),
|
|
36
47
|
staleTime: 3e4
|
|
37
48
|
}))
|
|
38
|
-
}),
|
|
39
|
-
return
|
|
40
|
-
var
|
|
49
|
+
}), s = l.map((t) => t.dataUpdatedAt).join(",");
|
|
50
|
+
return h(() => {
|
|
51
|
+
var n;
|
|
41
52
|
const t = {};
|
|
42
|
-
for (const
|
|
43
|
-
const
|
|
44
|
-
|
|
53
|
+
for (const o of r) {
|
|
54
|
+
const a = d.findIndex((f) => f.target === o.target && f.id === o.id), u = (n = l[a]) == null ? void 0 : n.data;
|
|
55
|
+
u && (t[o.path] = u[o.rest] ?? null);
|
|
45
56
|
}
|
|
46
57
|
return t;
|
|
47
|
-
}, [
|
|
58
|
+
}, [s, r.map((t) => `${t.path}=${t.id}`).join("|")]);
|
|
48
59
|
}
|
|
49
60
|
export {
|
|
50
|
-
|
|
51
|
-
|
|
61
|
+
_ as keepResolvedPaths,
|
|
62
|
+
y as pathsToPreview,
|
|
63
|
+
b as useHeaderPathPreview
|
|
52
64
|
};
|
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
2
|
+
import { useQuery as f } from "@tanstack/react-query";
|
|
3
|
+
import { useOptionalNivaroClient as m } from "../../context.js";
|
|
4
|
+
import { get as g } from "../../lib/commands.js";
|
|
5
|
+
import { describeError as p } from "../../lib/error-message.js";
|
|
6
|
+
import { cn as h } from "../../lib/utils.js";
|
|
7
|
+
function u(t) {
|
|
8
|
+
if (t == null)
|
|
6
9
|
return {
|
|
7
10
|
kind: "no-access",
|
|
8
11
|
text: "Not available to you",
|
|
9
12
|
tip: "Your access does not include this record."
|
|
10
13
|
};
|
|
11
|
-
const
|
|
12
|
-
return
|
|
14
|
+
const e = p(t).kind;
|
|
15
|
+
return e === "forbidden" || e === "signed-out" ? {
|
|
13
16
|
kind: "no-access",
|
|
14
17
|
text: "Not available to you",
|
|
15
18
|
tip: "Your access does not include this record."
|
|
16
|
-
} :
|
|
19
|
+
} : e === "not-found" ? {
|
|
17
20
|
kind: "not-found",
|
|
18
21
|
text: "Record not found",
|
|
19
22
|
tip: "It may have been deleted, or it is outside what you can see."
|
|
@@ -23,23 +26,76 @@ function i(e) {
|
|
|
23
26
|
tip: "The linked record didn’t load. Reload the page to try again."
|
|
24
27
|
};
|
|
25
28
|
}
|
|
26
|
-
function
|
|
27
|
-
return
|
|
29
|
+
function E(t, e) {
|
|
30
|
+
return u(e).kind !== "failed" ? !1 : t < 2;
|
|
28
31
|
}
|
|
29
|
-
function
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
function k(t) {
|
|
33
|
+
var o, s, n;
|
|
34
|
+
const e = (t == null ? void 0 : t.reasons) ?? [];
|
|
35
|
+
if (e.length === 0) return null;
|
|
36
|
+
const i = e.find((a) => a.type === "not_found");
|
|
37
|
+
return i ? {
|
|
38
|
+
kind: "not-found",
|
|
39
|
+
text: "Record not found",
|
|
40
|
+
// The server's sentence says when it was deleted, by whom and that it
|
|
41
|
+
// can be restored: more use than a fixed "was removed".
|
|
42
|
+
tip: ((o = i.message) == null ? void 0 : o.trim()) || "This record was removed."
|
|
43
|
+
} : {
|
|
44
|
+
kind: "no-access",
|
|
45
|
+
text: "Not available to you",
|
|
46
|
+
tip: ((n = (s = e.find((a) => {
|
|
47
|
+
var d;
|
|
48
|
+
return (d = a.message) == null ? void 0 : d.trim();
|
|
49
|
+
})) == null ? void 0 : s.message) == null ? void 0 : n.trim()) ?? "Your access does not include this record."
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
const x = /^(nivaro|directus)_/i;
|
|
53
|
+
function y(t, e, i) {
|
|
54
|
+
const r = m(), o = u(t), s = !!r && o.kind === "not-found" && !!e && !x.test(e) && i != null && i !== "", { data: n, isLoading: a } = f({
|
|
55
|
+
// Its own key: the denied panel keeps a differently shaped answer for a
|
|
56
|
+
// record page under 'access-explain'.
|
|
57
|
+
queryKey: ["related-missing-explain", e, String(i)],
|
|
58
|
+
queryFn: () => r.request(
|
|
59
|
+
g(`/access-explain/${e}/${encodeURIComponent(String(i))}`)
|
|
60
|
+
).then((d) => d.data ?? null).catch(() => null),
|
|
61
|
+
enabled: s,
|
|
62
|
+
staleTime: 5 * 6e4,
|
|
63
|
+
retry: !1
|
|
64
|
+
});
|
|
65
|
+
return s ? { missing: k(n) ?? o, settling: a } : { missing: o, settling: !1 };
|
|
66
|
+
}
|
|
67
|
+
const b = "inline-block h-3.5 w-20 animate-pulse rounded bg-slate-100 align-middle dark:bg-[hsl(var(--nvr-skeleton))]";
|
|
68
|
+
function M({
|
|
69
|
+
error: t,
|
|
70
|
+
collection: e,
|
|
71
|
+
id: i,
|
|
72
|
+
className: r,
|
|
73
|
+
settlingClassName: o = b,
|
|
74
|
+
labelId: s
|
|
75
|
+
}) {
|
|
76
|
+
const { missing: n, settling: a } = y(t, e, i);
|
|
77
|
+
return a ? /* @__PURE__ */ c("span", { "aria-hidden": "true", "data-related-unavailable-settling": "", className: o }) : /* @__PURE__ */ l(
|
|
32
78
|
"span",
|
|
33
79
|
{
|
|
34
|
-
|
|
80
|
+
id: s,
|
|
81
|
+
className: h("italic text-muted-foreground", s && "relative", r),
|
|
35
82
|
"data-related-unavailable": n.kind,
|
|
36
|
-
"data-tip": n.tip
|
|
37
|
-
children:
|
|
83
|
+
"data-tip": `${n.text}. ${n.tip}`,
|
|
84
|
+
children: [
|
|
85
|
+
n.text,
|
|
86
|
+
s && /* @__PURE__ */ l("span", { className: "sr-only", children: [
|
|
87
|
+
". ",
|
|
88
|
+
n.tip
|
|
89
|
+
] })
|
|
90
|
+
]
|
|
38
91
|
}
|
|
39
92
|
);
|
|
40
93
|
}
|
|
41
94
|
export {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
95
|
+
b as RELATED_LOADING_CLASS,
|
|
96
|
+
M as RelatedMissingLabel,
|
|
97
|
+
k as explainedMissing,
|
|
98
|
+
u as relatedMissing,
|
|
99
|
+
E as retryRelatedRead,
|
|
100
|
+
y as useRelatedMissing
|
|
45
101
|
};
|
|
@@ -81,7 +81,6 @@ function w({ delivery: n, mailLogUrl: e, onNavigate: s, className: o }) {
|
|
|
81
81
|
{
|
|
82
82
|
type: "button",
|
|
83
83
|
"data-tip": `${a.tip} · open mail log`,
|
|
84
|
-
title: a.tip,
|
|
85
84
|
onClick: (p) => {
|
|
86
85
|
p.stopPropagation(), s == null || s(i);
|
|
87
86
|
},
|
|
@@ -89,7 +88,7 @@ function w({ delivery: n, mailLogUrl: e, onNavigate: s, className: o }) {
|
|
|
89
88
|
children: t
|
|
90
89
|
},
|
|
91
90
|
a.key
|
|
92
|
-
) : /* @__PURE__ */ m("span", { "data-tip": a.tip,
|
|
91
|
+
) : /* @__PURE__ */ m("span", { "data-tip": a.tip, className: d, children: t }, a.key);
|
|
93
92
|
})
|
|
94
93
|
}
|
|
95
94
|
);
|