@nivaro/react 0.3.3 → 0.3.5
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/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +33 -1
- package/dist/index.js +288 -286
- package/dist/shared/components/RecordReadView.js +116 -115
- package/dist/shared/components/item-edit/M2MCombobox.js +57 -56
- package/dist/shared/context.js +96 -84
- package/dist/shared/lib/allowed-collections.js +15 -0
- package/dist/shared/lib/request-gate.js +190 -178
- package/package.json +1 -1
|
@@ -1,72 +1,73 @@
|
|
|
1
1
|
import { jsx as n, jsxs as c } from "react/jsx-runtime";
|
|
2
|
-
import { useQuery as
|
|
2
|
+
import { useQuery as w } from "@tanstack/react-query";
|
|
3
3
|
import { ChevronDown as te, Loader2 as ae, AlertTriangle as ce, X as oe, Check as de } from "lucide-react";
|
|
4
4
|
import { useState as ne, useRef as me, useEffect as ue } from "react";
|
|
5
5
|
import { useNivaroClient as fe, useItemEditAuth as pe, useDrilldown as $e } from "../../context.js";
|
|
6
|
+
import { parseAllowedCollections as Ie } from "../../lib/allowed-collections.js";
|
|
6
7
|
import { get as C } from "../../lib/commands.js";
|
|
7
|
-
import { useRecordReader as
|
|
8
|
+
import { useRecordReader as Ae } from "../../lib/record-loader.js";
|
|
8
9
|
import { useOnlineUsers as he } from "../../lib/use-online-users.js";
|
|
9
10
|
import { cn as Q, userOptionFilter as ye } from "../../lib/utils.js";
|
|
10
11
|
import { UserAvatar as be } from "../UserAvatar.js";
|
|
11
|
-
import { Command as xe, CommandInput as ge, CommandList as ve, CommandEmpty as ke, CommandGroup as
|
|
12
|
+
import { Command as xe, CommandInput as ge, CommandList as ve, CommandEmpty as ke, CommandGroup as we, CommandItem as Ne } from "../ui/command.js";
|
|
12
13
|
import { Popover as Se, PopoverTrigger as _e, PopoverContent as Ce } from "../ui/popover.js";
|
|
13
14
|
import { applyDisplayTemplate as qe } from "./helpers.js";
|
|
14
15
|
import { useM2MStaging as Le } from "./M2MStagingContext.js";
|
|
15
|
-
import { useStaleTip as
|
|
16
|
+
import { useStaleTip as Ke, RelatedItemLabel as ie } from "./RelationCombobox.js";
|
|
16
17
|
function je(s) {
|
|
17
|
-
return s.replace(/\(.*$/, "").trim().split(/\s+/).map((
|
|
18
|
+
return s.replace(/\(.*$/, "").trim().split(/\s+/).map((o) => o[0]).filter(Boolean).slice(0, 2).join("").toUpperCase() || "?";
|
|
18
19
|
}
|
|
19
20
|
function Fe(s) {
|
|
20
|
-
return (
|
|
21
|
+
return Ie(s == null ? void 0 : s.one_allowed_collections);
|
|
21
22
|
}
|
|
22
23
|
function Te(s) {
|
|
23
24
|
if (!s) return null;
|
|
24
25
|
if (s.one_collection) return s.one_collection;
|
|
25
|
-
const
|
|
26
|
-
return
|
|
26
|
+
const o = Fe(s);
|
|
27
|
+
return o.length === 0 ? null : o.some((N) => N === "directus_users" || N === "nivaro_users") ? "nivaro_users" : o[0];
|
|
27
28
|
}
|
|
28
|
-
function
|
|
29
|
+
function et(s) {
|
|
29
30
|
if (!s || s.one_collection) return null;
|
|
30
|
-
const
|
|
31
|
-
if (
|
|
32
|
-
const
|
|
33
|
-
return { field: s.one_collection_field ?? "collection", value:
|
|
31
|
+
const o = Fe(s);
|
|
32
|
+
if (o.length === 0) return null;
|
|
33
|
+
const N = o.includes("directus_users") ? "directus_users" : o.includes("nivaro_users") ? "nivaro_users" : o[0];
|
|
34
|
+
return { field: s.one_collection_field ?? "collection", value: N };
|
|
34
35
|
}
|
|
35
|
-
function
|
|
36
|
+
function tt({
|
|
36
37
|
relation: s,
|
|
37
|
-
parentId:
|
|
38
|
-
allRelations:
|
|
38
|
+
parentId: o,
|
|
39
|
+
allRelations: N,
|
|
39
40
|
extraFilter: h,
|
|
40
41
|
optionSort: y,
|
|
41
42
|
requiredParent: K,
|
|
42
43
|
onCountChange: J,
|
|
43
44
|
drilldown: D
|
|
44
45
|
}) {
|
|
45
|
-
const b = fe(), W = $e(), t = Le(), [P, q] = ne(!1), [L, T] = ne(""), le =
|
|
46
|
+
const b = fe(), W = $e(), t = Le(), [P, q] = ne(!1), [L, T] = ne(""), le = N.find(
|
|
46
47
|
(e) => e.many_collection === s.many_collection && e.many_field === s.junction_field && e.id !== s.id
|
|
47
|
-
), r = Te(le), x = s.junction_field ?? "", z = s.many_field ?? "", d = s.one_field ?? `${s.many_collection}.${x}`, { data:
|
|
48
|
+
), r = Te(le), x = s.junction_field ?? "", z = s.many_field ?? "", d = s.one_field ?? `${s.many_collection}.${x}`, { data: a } = w({
|
|
48
49
|
queryKey: ["col-meta", r],
|
|
49
50
|
queryFn: () => b.request(C(`/collections/${r}`)).then((e) => e.data),
|
|
50
51
|
enabled: !!r,
|
|
51
52
|
staleTime: 3e5,
|
|
52
53
|
retry: !1
|
|
53
|
-
}), { data: X = [] } =
|
|
54
|
-
queryKey: ["m2m-items", s.many_collection, z,
|
|
54
|
+
}), { data: X = [] } = w({
|
|
55
|
+
queryKey: ["m2m-items", s.many_collection, z, o],
|
|
55
56
|
queryFn: () => b.request(
|
|
56
57
|
C(`/items/${s.many_collection}`, {
|
|
57
|
-
filter: JSON.stringify({ [z]: { _eq:
|
|
58
|
+
filter: JSON.stringify({ [z]: { _eq: o } }),
|
|
58
59
|
limit: 200,
|
|
59
60
|
fields: `id,${x}`
|
|
60
61
|
})
|
|
61
62
|
).then((e) => e.data ?? []),
|
|
62
63
|
staleTime: 3e4,
|
|
63
|
-
enabled: !!
|
|
64
|
+
enabled: !!o && o !== "new"
|
|
64
65
|
}), re = pe().isAdmin, E = r === "nivaro_users" ? ye(re) : null, R = he(r === "nivaro_users"), H = h ? E ? { _and: [h, E] } : h : E, j = H ? JSON.stringify(H) : void 0, g = y && !/^-?label$/.test(y) ? y : void 0, S = (() => {
|
|
65
|
-
const e =
|
|
66
|
+
const e = a == null ? void 0 : a.display_template;
|
|
66
67
|
if (!e || !e.includes(".")) return null;
|
|
67
68
|
const i = [...e.matchAll(/\{\{([^}]+)\}\}/g)].map((u) => u[1].trim());
|
|
68
69
|
return i.length === 0 ? null : ["id", ...i].join(",");
|
|
69
|
-
})(), { data: O = [], isFetching:
|
|
70
|
+
})(), { data: O = [], isFetching: V } = w({
|
|
70
71
|
queryKey: [
|
|
71
72
|
"m2m-options",
|
|
72
73
|
r,
|
|
@@ -89,7 +90,7 @@ function Me({
|
|
|
89
90
|
).then((e) => e.data ?? []),
|
|
90
91
|
enabled: P && !!r,
|
|
91
92
|
staleTime: j ? 0 : 3e4
|
|
92
|
-
}),
|
|
93
|
+
}), B = (t == null ? void 0 : t.getStagedLinks(d)) ?? [], v = (t == null ? void 0 : t.getStagedUnlinks(d)) ?? /* @__PURE__ */ new Set(), U = X.filter((e) => !v.has(e.id)), p = new Set(U.map((e) => String(e[x]))), _ = [...p], Y = JSON.stringify(h ? { _and: [{ id: { _in: _ } }, h] } : { id: { _in: _ } }), { data: m } = w({
|
|
93
94
|
queryKey: ["m2m-avail", r, _.join(","), j],
|
|
94
95
|
queryFn: () => b.request(
|
|
95
96
|
C(`/items/${r}`, {
|
|
@@ -101,7 +102,7 @@ function Me({
|
|
|
101
102
|
).then((e) => e.data ?? []),
|
|
102
103
|
enabled: !!r && _.length > 0,
|
|
103
104
|
staleTime: 3e4
|
|
104
|
-
}), Z = new Set((m ?? []).map((e) => String(e.id))), $ = m !== void 0 ? new Set(_.filter((e) => !Z.has(e))) : /* @__PURE__ */ new Set(), I = new Set(
|
|
105
|
+
}), Z = new Set((m ?? []).map((e) => String(e.id))), $ = m !== void 0 ? new Set(_.filter((e) => !Z.has(e))) : /* @__PURE__ */ new Set(), I = new Set(B.map(String)), A = /* @__PURE__ */ new Set([...p, ...I]), F = me(J);
|
|
105
106
|
F.current = J, ue(() => {
|
|
106
107
|
var e;
|
|
107
108
|
(e = F.current) == null || e.call(F, A.size);
|
|
@@ -120,7 +121,7 @@ function Me({
|
|
|
120
121
|
t == null || t.stageLink(d, e);
|
|
121
122
|
}
|
|
122
123
|
function k(e) {
|
|
123
|
-
const i = (
|
|
124
|
+
const i = (a == null ? void 0 : a.display_template) ?? null;
|
|
124
125
|
return i ? qe(i, e) : String(e._display ?? e.id ?? "");
|
|
125
126
|
}
|
|
126
127
|
return K ? /* @__PURE__ */ c(
|
|
@@ -193,7 +194,7 @@ function Me({
|
|
|
193
194
|
{
|
|
194
195
|
collection: r,
|
|
195
196
|
id: i,
|
|
196
|
-
displayTemplate:
|
|
197
|
+
displayTemplate: a == null ? void 0 : a.display_template
|
|
197
198
|
}
|
|
198
199
|
)
|
|
199
200
|
}
|
|
@@ -202,7 +203,7 @@ function Me({
|
|
|
202
203
|
{
|
|
203
204
|
collection: r,
|
|
204
205
|
id: i,
|
|
205
|
-
displayTemplate:
|
|
206
|
+
displayTemplate: a == null ? void 0 : a.display_template
|
|
206
207
|
}
|
|
207
208
|
)),
|
|
208
209
|
/* @__PURE__ */ n(
|
|
@@ -219,7 +220,7 @@ function Me({
|
|
|
219
220
|
String(e.id)
|
|
220
221
|
);
|
|
221
222
|
}),
|
|
222
|
-
|
|
223
|
+
B.map((e) => /* @__PURE__ */ c(
|
|
223
224
|
"span",
|
|
224
225
|
{
|
|
225
226
|
className: "inline-flex items-center gap-1 rounded-full border border-dashed border-nvr-cyan/50 bg-nvr-cyan/5 pl-2.5 pr-1.5 py-0.5 text-[12px] text-slate-600 dark:text-slate-300",
|
|
@@ -229,7 +230,7 @@ function Me({
|
|
|
229
230
|
{
|
|
230
231
|
collection: r,
|
|
231
232
|
id: e,
|
|
232
|
-
displayTemplate:
|
|
233
|
+
displayTemplate: a == null ? void 0 : a.display_template
|
|
233
234
|
}
|
|
234
235
|
) : String(e),
|
|
235
236
|
/* @__PURE__ */ n(
|
|
@@ -263,13 +264,13 @@ function Me({
|
|
|
263
264
|
}
|
|
264
265
|
),
|
|
265
266
|
/* @__PURE__ */ c(ve, { children: [
|
|
266
|
-
|
|
267
|
-
/* @__PURE__ */ n(
|
|
267
|
+
V ? /* @__PURE__ */ n("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ n(ae, { className: "h-4 w-4 animate-spin text-muted-foreground" }) }) : /* @__PURE__ */ n(ke, { className: "py-3 text-left text-[12px] text-muted-foreground px-3", children: "No results" }),
|
|
268
|
+
/* @__PURE__ */ n(we, { children: !V && (g ? [...O] : [...O].sort(
|
|
268
269
|
(e, i) => y === "-label" ? k(i).localeCompare(k(e)) : k(e).localeCompare(k(i))
|
|
269
270
|
)).map((e) => {
|
|
270
271
|
const i = String(e.id), u = A.has(i);
|
|
271
272
|
return /* @__PURE__ */ c(
|
|
272
|
-
|
|
273
|
+
Ne,
|
|
273
274
|
{
|
|
274
275
|
value: i,
|
|
275
276
|
onSelect: () => G(e.id),
|
|
@@ -312,41 +313,41 @@ function Me({
|
|
|
312
313
|
}
|
|
313
314
|
) });
|
|
314
315
|
}
|
|
315
|
-
function
|
|
316
|
+
function nt({
|
|
316
317
|
relation: s,
|
|
317
|
-
parentId:
|
|
318
|
-
allRelations:
|
|
318
|
+
parentId: o,
|
|
319
|
+
allRelations: N,
|
|
319
320
|
extraFilter: h,
|
|
320
321
|
optionSort: y,
|
|
321
322
|
requiredParent: K,
|
|
322
323
|
onCountChange: J,
|
|
323
324
|
readOnly: D
|
|
324
325
|
}) {
|
|
325
|
-
const b = fe(), W =
|
|
326
|
+
const b = fe(), W = Ae(), t = Le(), [P, q] = ne(!1), [L, T] = ne(""), le = N.find(
|
|
326
327
|
(l) => l.many_collection === s.many_collection && l.many_field === s.junction_field && l.id !== s.id
|
|
327
|
-
), r = Te(le), x = s.junction_field ?? "", z = s.many_field ?? "", d = s.one_field ?? `${s.many_collection}.${x}`, { data:
|
|
328
|
+
), r = Te(le), x = s.junction_field ?? "", z = s.many_field ?? "", d = s.one_field ?? `${s.many_collection}.${x}`, { data: a } = w({
|
|
328
329
|
queryKey: ["col-meta", r],
|
|
329
330
|
queryFn: () => b.request(C(`/collections/${r}`)).then((l) => l.data),
|
|
330
331
|
enabled: !!r,
|
|
331
332
|
staleTime: 3e5,
|
|
332
333
|
retry: !1
|
|
333
|
-
}), { data: X = [], isFetching: re } =
|
|
334
|
-
queryKey: ["m2m-items", s.many_collection, z,
|
|
334
|
+
}), { data: X = [], isFetching: re } = w({
|
|
335
|
+
queryKey: ["m2m-items", s.many_collection, z, o],
|
|
335
336
|
queryFn: () => b.request(
|
|
336
337
|
C(`/items/${s.many_collection}`, {
|
|
337
|
-
filter: JSON.stringify({ [z]: { _eq:
|
|
338
|
+
filter: JSON.stringify({ [z]: { _eq: o } }),
|
|
338
339
|
limit: 1,
|
|
339
340
|
fields: `id,${x}`
|
|
340
341
|
})
|
|
341
342
|
).then((l) => l.data ?? []),
|
|
342
343
|
staleTime: 3e4,
|
|
343
|
-
enabled: !!
|
|
344
|
+
enabled: !!o && o !== "new"
|
|
344
345
|
}), E = pe().isAdmin, R = r === "nivaro_users" ? ye(E) : null, H = he(r === "nivaro_users"), j = h ? R ? { _and: [h, R] } : h : R, g = j ? JSON.stringify(j) : void 0, S = y && !/^-?label$/.test(y) ? y : void 0, O = (() => {
|
|
345
|
-
const l =
|
|
346
|
+
const l = a == null ? void 0 : a.display_template;
|
|
346
347
|
if (!l || !l.includes(".")) return null;
|
|
347
348
|
const f = [...l.matchAll(/\{\{([^}]+)\}\}/g)].map((ee) => ee[1].trim());
|
|
348
349
|
return f.length === 0 ? null : ["id", ...f].join(",");
|
|
349
|
-
})(), { data:
|
|
350
|
+
})(), { data: V = [], isFetching: B } = w({
|
|
350
351
|
queryKey: [
|
|
351
352
|
"m2m-options",
|
|
352
353
|
r,
|
|
@@ -374,12 +375,12 @@ function et({
|
|
|
374
375
|
var l;
|
|
375
376
|
(l = $.current) == null || l.call($, m != null ? 1 : 0);
|
|
376
377
|
}, [m]);
|
|
377
|
-
const { data: I } =
|
|
378
|
+
const { data: I } = w({
|
|
378
379
|
queryKey: ["relation-single", r, String(m)],
|
|
379
380
|
queryFn: () => W(r, m),
|
|
380
381
|
enabled: !!r && m != null,
|
|
381
382
|
staleTime: 6e4
|
|
382
|
-
}), A = JSON.stringify(h ? { _and: [{ id: { _eq: m } }, h] } : { id: { _eq: m } }), { data: F } =
|
|
383
|
+
}), A = JSON.stringify(h ? { _and: [{ id: { _eq: m } }, h] } : { id: { _eq: m } }), { data: F } = w({
|
|
383
384
|
queryKey: ["relation-avail", r, String(m), g],
|
|
384
385
|
queryFn: () => b.request(
|
|
385
386
|
C(`/items/${r}`, {
|
|
@@ -391,11 +392,11 @@ function et({
|
|
|
391
392
|
).then((l) => l.data ?? []),
|
|
392
393
|
enabled: !!r && m != null && !!I,
|
|
393
394
|
staleTime: 3e4
|
|
394
|
-
}), G = F !== void 0 && F.length === 0, k =
|
|
395
|
+
}), G = F !== void 0 && F.length === 0, k = Ke(G), e = (a == null ? void 0 : a.display_template) ?? null;
|
|
395
396
|
function i(l) {
|
|
396
397
|
return e ? qe(e, l) : String(l.name ?? l.title ?? l.label ?? l.id ?? "");
|
|
397
398
|
}
|
|
398
|
-
const u =
|
|
399
|
+
const u = V.find((l) => String(l.id) === String(m)) ?? I, M = m != null && !I && !u, se = u ? i(u) : null;
|
|
399
400
|
if (D)
|
|
400
401
|
return /* @__PURE__ */ n("span", { className: "block truncate text-[12px] text-slate-700 dark:text-slate-200", children: M ? "…" : se ?? "—" });
|
|
401
402
|
function Oe(l) {
|
|
@@ -439,7 +440,7 @@ function et({
|
|
|
439
440
|
G ? "border-amber-300 dark:border-amber-600" : Z ? "border-nvr-cyan/50" : "border-input"
|
|
440
441
|
),
|
|
441
442
|
children: [
|
|
442
|
-
M || re && Y == null &&
|
|
443
|
+
M || re && Y == null && o !== "new" ? /* @__PURE__ */ n(ae, { className: "h-3.5 w-3.5 animate-spin text-muted-foreground" }) : /* @__PURE__ */ c(
|
|
443
444
|
"span",
|
|
444
445
|
{
|
|
445
446
|
className: Q(
|
|
@@ -481,13 +482,13 @@ function et({
|
|
|
481
482
|
}
|
|
482
483
|
),
|
|
483
484
|
/* @__PURE__ */ c(ve, { children: [
|
|
484
|
-
|
|
485
|
-
!
|
|
485
|
+
B ? /* @__PURE__ */ n("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ n(ae, { className: "h-4 w-4 animate-spin text-muted-foreground" }) }) : /* @__PURE__ */ n(ke, { className: "py-3 text-left text-[12px] text-muted-foreground px-3", children: "No results" }),
|
|
486
|
+
!B && /* @__PURE__ */ n(we, { children: [...V].sort(
|
|
486
487
|
(l, f) => S ? 0 : y === "-label" ? i(f).localeCompare(i(l)) : i(l).localeCompare(i(f))
|
|
487
488
|
).map((l) => {
|
|
488
489
|
const f = String(l.id), ee = String(m) === f;
|
|
489
490
|
return /* @__PURE__ */ c(
|
|
490
|
-
|
|
491
|
+
Ne,
|
|
491
492
|
{
|
|
492
493
|
value: f,
|
|
493
494
|
onSelect: () => Oe(l.id),
|
|
@@ -533,8 +534,8 @@ function et({
|
|
|
533
534
|
] });
|
|
534
535
|
}
|
|
535
536
|
export {
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
537
|
+
tt as M2MCombobox,
|
|
538
|
+
nt as M2MSingleSelectCombobox,
|
|
539
|
+
et as m2aWriteMeta,
|
|
539
540
|
Te as resolveM2MRelatedCollection
|
|
540
541
|
};
|
package/dist/shared/context.js
CHANGED
|
@@ -1,75 +1,87 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { QueryClientContext as
|
|
3
|
-
import { createContext as i, useContext as l, useState as
|
|
4
|
-
import { restoreMetadata as
|
|
5
|
-
import { isCoalesced as
|
|
6
|
-
const
|
|
7
|
-
function
|
|
8
|
-
return l(
|
|
9
|
-
}
|
|
10
|
-
const
|
|
11
|
-
function
|
|
12
|
-
const t =
|
|
13
|
-
return
|
|
1
|
+
import { jsxs as b, jsx as f } from "react/jsx-runtime";
|
|
2
|
+
import { QueryClientContext as v, QueryClient as w, QueryClientProvider as g, useQueryClient as C } from "@tanstack/react-query";
|
|
3
|
+
import { createContext as i, useContext as l, useState as m, useMemo as x, useCallback as h, useEffect as y } from "react";
|
|
4
|
+
import { restoreMetadata as I, startMetadataPersistence as N } from "./lib/metadata-persist.js";
|
|
5
|
+
import { isCoalesced as O, withGetCoalescing as P, releaseGatedReadsOnSharedFetch as S } from "./lib/request-gate.js";
|
|
6
|
+
const F = i(null);
|
|
7
|
+
function z() {
|
|
8
|
+
return l(F);
|
|
9
|
+
}
|
|
10
|
+
const p = i(null);
|
|
11
|
+
function $({ identity: e }) {
|
|
12
|
+
const t = C(), { userId: n, epoch: o, version: r } = e;
|
|
13
|
+
return y(() => {
|
|
14
14
|
let u = () => {
|
|
15
15
|
}, c = !1;
|
|
16
|
-
return
|
|
17
|
-
c || (u =
|
|
16
|
+
return I(t, { userId: n, epoch: o, version: r }).then(() => {
|
|
17
|
+
c || (u = N(t, { userId: n, epoch: o, version: r }));
|
|
18
18
|
}), () => {
|
|
19
19
|
c = !0, u();
|
|
20
20
|
};
|
|
21
21
|
}, [t, n, o, r]), null;
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
const d = /* @__PURE__ */ new WeakMap();
|
|
24
|
+
function j() {
|
|
25
|
+
const e = C();
|
|
26
|
+
return y(() => {
|
|
27
|
+
const t = e.getQueryCache(), n = d.get(t);
|
|
28
|
+
return n ? n.count++ : d.set(t, { count: 1, stop: S(t) }), () => {
|
|
29
|
+
const o = d.get(t);
|
|
30
|
+
o && (o.count--, o.count <= 0 && (o.stop(), d.delete(t)));
|
|
31
|
+
};
|
|
32
|
+
}, [e]), null;
|
|
33
|
+
}
|
|
34
|
+
function L({
|
|
24
35
|
client: e,
|
|
25
36
|
children: t,
|
|
26
37
|
batchReads: n = !1,
|
|
27
38
|
persistMetadata: o = null
|
|
28
39
|
}) {
|
|
29
|
-
const r = l(
|
|
30
|
-
() => new
|
|
40
|
+
const r = l(v), [u] = m(
|
|
41
|
+
() => new w({
|
|
31
42
|
defaultOptions: { queries: { retry: 1, refetchOnWindowFocus: !1 } }
|
|
32
43
|
})
|
|
33
|
-
), c =
|
|
34
|
-
() =>
|
|
44
|
+
), c = x(
|
|
45
|
+
() => O(e) ? e : P(e, { batchReads: n }),
|
|
35
46
|
[e, n]
|
|
36
|
-
), s = /* @__PURE__ */
|
|
37
|
-
o ? /* @__PURE__ */ f(
|
|
47
|
+
), s = /* @__PURE__ */ b(p.Provider, { value: { client: c }, children: [
|
|
48
|
+
o ? /* @__PURE__ */ f($, { identity: o }) : null,
|
|
49
|
+
typeof e.setOpen == "function" ? /* @__PURE__ */ f(j, {}) : null,
|
|
38
50
|
t
|
|
39
51
|
] });
|
|
40
|
-
return r ? s : /* @__PURE__ */ f(
|
|
52
|
+
return r ? s : /* @__PURE__ */ f(g, { client: u, children: s });
|
|
41
53
|
}
|
|
42
|
-
function
|
|
43
|
-
const e = l(
|
|
54
|
+
function K() {
|
|
55
|
+
const e = l(p);
|
|
44
56
|
if (!e) throw new Error("useNivaroClient must be used within <NivaroProvider>");
|
|
45
57
|
return e.client;
|
|
46
58
|
}
|
|
47
|
-
function
|
|
48
|
-
const e = l(
|
|
59
|
+
function D() {
|
|
60
|
+
const e = l(p);
|
|
49
61
|
return (e == null ? void 0 : e.client) ?? null;
|
|
50
62
|
}
|
|
51
|
-
function
|
|
52
|
-
const e =
|
|
63
|
+
function X() {
|
|
64
|
+
const e = D(), t = e == null ? void 0 : e.getToken();
|
|
53
65
|
return {
|
|
54
66
|
apiBase: e ? `${e.url}/api` : "/api",
|
|
55
67
|
authHeaders: t ? { Authorization: `Bearer ${t}` } : {},
|
|
56
68
|
credentials: t ? "omit" : "include"
|
|
57
69
|
};
|
|
58
70
|
}
|
|
59
|
-
const
|
|
71
|
+
const R = i({
|
|
60
72
|
isAdmin: !1,
|
|
61
73
|
userId: ""
|
|
62
74
|
});
|
|
63
|
-
function
|
|
64
|
-
return l(
|
|
75
|
+
function Y() {
|
|
76
|
+
return l(R);
|
|
65
77
|
}
|
|
66
|
-
function
|
|
78
|
+
function A(e) {
|
|
67
79
|
const t = JSON.stringify(e), n = new TextEncoder().encode(t);
|
|
68
80
|
let o = "";
|
|
69
81
|
for (const r of n) o += String.fromCharCode(r);
|
|
70
82
|
return encodeURIComponent(btoa(o));
|
|
71
83
|
}
|
|
72
|
-
function
|
|
84
|
+
function Z(e) {
|
|
73
85
|
if (!e) return null;
|
|
74
86
|
try {
|
|
75
87
|
const t = atob(e.replace(/ /g, "+")), n = Uint8Array.from(t, (r) => r.charCodeAt(0)), o = JSON.parse(new TextDecoder().decode(n));
|
|
@@ -83,52 +95,52 @@ function K(e) {
|
|
|
83
95
|
}
|
|
84
96
|
}
|
|
85
97
|
}
|
|
86
|
-
const
|
|
98
|
+
const Q = i({
|
|
87
99
|
navigate: (e) => {
|
|
88
100
|
window.location.href = e;
|
|
89
101
|
}
|
|
90
102
|
});
|
|
91
|
-
function
|
|
92
|
-
return l(
|
|
103
|
+
function U() {
|
|
104
|
+
return l(Q);
|
|
93
105
|
}
|
|
94
|
-
function
|
|
106
|
+
function k(e) {
|
|
95
107
|
const t = `/collections/${e.collection}/${e.itemId}`, n = [];
|
|
96
|
-
e.layoutSlug && n.push(`layout=${encodeURIComponent(e.layoutSlug)}`), e.prefill && Object.keys(e.prefill).length && n.push(`prefill=${
|
|
108
|
+
e.layoutSlug && n.push(`layout=${encodeURIComponent(e.layoutSlug)}`), e.prefill && Object.keys(e.prefill).length && n.push(`prefill=${A(e.prefill)}`);
|
|
97
109
|
for (const [o, r] of Object.entries(e.query ?? {}))
|
|
98
110
|
n.push(`${encodeURIComponent(o)}=${encodeURIComponent(r)}`);
|
|
99
111
|
return n.length ? `${t}?${n.join("&")}` : t;
|
|
100
112
|
}
|
|
101
|
-
function
|
|
102
|
-
const e =
|
|
113
|
+
function ee() {
|
|
114
|
+
const e = U(), t = (o) => (e.itemUrl ?? k)(o);
|
|
103
115
|
return { urlFor: t, open: (o) => {
|
|
104
116
|
var r;
|
|
105
117
|
((r = e.openItem) == null ? void 0 : r.call(e, o)) !== !0 && e.navigate(t(o));
|
|
106
118
|
} };
|
|
107
119
|
}
|
|
108
|
-
const U = i(null);
|
|
109
|
-
function Y() {
|
|
110
|
-
return l(U);
|
|
111
|
-
}
|
|
112
120
|
const E = i(null);
|
|
113
|
-
function
|
|
121
|
+
function te() {
|
|
114
122
|
return l(E);
|
|
115
123
|
}
|
|
116
|
-
const
|
|
117
|
-
function
|
|
118
|
-
return l(
|
|
124
|
+
const G = i(null);
|
|
125
|
+
function ne() {
|
|
126
|
+
return l(G);
|
|
119
127
|
}
|
|
120
|
-
const
|
|
121
|
-
function
|
|
122
|
-
return l(
|
|
128
|
+
const M = i({});
|
|
129
|
+
function oe() {
|
|
130
|
+
return l(M);
|
|
131
|
+
}
|
|
132
|
+
const q = i(null);
|
|
133
|
+
function re() {
|
|
134
|
+
return l(q);
|
|
123
135
|
}
|
|
124
136
|
const H = i(null);
|
|
125
|
-
function
|
|
126
|
-
const t = l(H), [n, o] =
|
|
137
|
+
function le(e) {
|
|
138
|
+
const t = l(H), [n, o] = m([]), r = t ? t.get(e) ?? null : n[n.length - 1] ?? null, u = h(
|
|
127
139
|
(s) => {
|
|
128
140
|
t ? t.push(e, s) : o((a) => [...a, s]);
|
|
129
141
|
},
|
|
130
142
|
[t, e]
|
|
131
|
-
), c =
|
|
143
|
+
), c = h(
|
|
132
144
|
(s = 1) => {
|
|
133
145
|
t ? t.back(s) : o((a) => a.slice(0, Math.max(0, a.length - s)));
|
|
134
146
|
},
|
|
@@ -136,39 +148,39 @@ function ne(e) {
|
|
|
136
148
|
);
|
|
137
149
|
return { value: r, push: u, back: c };
|
|
138
150
|
}
|
|
139
|
-
function
|
|
151
|
+
function ie(e) {
|
|
140
152
|
var u;
|
|
141
153
|
const t = (u = e._overrides) == null ? void 0 : u.drilldown, n = t && typeof t == "object" ? t : null, o = e.interface === "relation-path";
|
|
142
154
|
return (n == null ? void 0 : n.enabled) ?? o ? { enabled: !0, layout_id: (n == null ? void 0 : n.layout_id) ?? null, width: (n == null ? void 0 : n.width) ?? null } : null;
|
|
143
155
|
}
|
|
144
|
-
const
|
|
156
|
+
const ue = i(null), W = i(null), se = () => l(W);
|
|
145
157
|
export {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
158
|
+
q as DrilldownContext,
|
|
159
|
+
M as DrilldownViewsContext,
|
|
160
|
+
F as GridFlushContext,
|
|
161
|
+
R as ItemEditAuthContext,
|
|
162
|
+
Q as NavigationContext,
|
|
163
|
+
L as NivaroProvider,
|
|
152
164
|
H as OverlayHistoryContext,
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
165
|
+
E as ParentDraftContext,
|
|
166
|
+
G as ReimportHandlerContext,
|
|
167
|
+
ue as RelationPathDataContext,
|
|
168
|
+
W as StaleFieldReportContext,
|
|
169
|
+
Z as decodePrefill,
|
|
170
|
+
k as defaultItemUrl,
|
|
171
|
+
A as encodePrefill,
|
|
172
|
+
ie as fieldDrilldownConfig,
|
|
173
|
+
X as useApiFetchConfig,
|
|
174
|
+
re as useDrilldown,
|
|
175
|
+
oe as useDrilldownViews,
|
|
176
|
+
z as useGridFlush,
|
|
177
|
+
Y as useItemEditAuth,
|
|
178
|
+
ee as useItemNavigation,
|
|
179
|
+
U as useNavigation,
|
|
180
|
+
K as useNivaroClient,
|
|
181
|
+
D as useOptionalNivaroClient,
|
|
182
|
+
le as useOverlayState,
|
|
183
|
+
te as useParentDraft,
|
|
184
|
+
ne as useReimportHandler,
|
|
185
|
+
se as useStaleFieldReporter
|
|
174
186
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
function n(t) {
|
|
2
|
+
if (t == null || t === "") return [];
|
|
3
|
+
if (Array.isArray(t)) return t.map((r) => String(r).trim()).filter(Boolean);
|
|
4
|
+
const i = String(t).trim();
|
|
5
|
+
if (i.startsWith("["))
|
|
6
|
+
try {
|
|
7
|
+
const r = JSON.parse(i);
|
|
8
|
+
if (Array.isArray(r)) return r.map((e) => String(e).trim()).filter(Boolean);
|
|
9
|
+
} catch {
|
|
10
|
+
}
|
|
11
|
+
return i.split(",").map((r) => r.trim()).filter(Boolean);
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
n as parseAllowedCollections
|
|
15
|
+
};
|