@nivaro/react 0.3.103 → 0.3.105

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 (28) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +15 -3
  4. package/dist/shared/components/CollectionBrowserView.js +1694 -1639
  5. package/dist/shared/components/ItemEditForm.js +2867 -2845
  6. package/dist/shared/components/imports/CollectionImportPanel.js +483 -459
  7. package/dist/shared/components/integrations/IntegrationStatusLines.js +71 -68
  8. package/dist/shared/components/item-edit/InlineTableField.js +88 -88
  9. package/dist/shared/components/item-edit/UserChip.js +38 -38
  10. package/dist/shared/components/layout-editor/DesignNode.js +16 -14
  11. package/dist/shared/components/layout-editor/LayoutEditor.js +445 -441
  12. package/dist/shared/components/layout-editor/inspector/Inspector.js +18 -18
  13. package/dist/shared/components/layout-editor/inspector/SlotInspector.js +80 -52
  14. package/dist/shared/components/layout-editor/parity-keys.json.js +1 -1
  15. package/dist/shared/components/layout-editor/settings/ButtonsSection.js +54 -26
  16. package/dist/shared/components/layout-editor/settings/settings-registry.js +23 -15
  17. package/dist/shared/components/layout-editor/useLayoutDraft.js +211 -196
  18. package/dist/shared/components/panels/ExternalRequestsChip.js +141 -122
  19. package/dist/shared/components/quick-filters/QuickFilterBarEditor.js +334 -0
  20. package/dist/shared/components/quick-filters/QuickFilterFieldPicker.js +151 -0
  21. package/dist/shared/components/quick-filters/QuickFilterForm.js +371 -0
  22. package/dist/shared/components/quick-filters/config.js +63 -0
  23. package/dist/shared/components/quick-filters/facets.js +55 -0
  24. package/dist/shared/components/quick-filters/useQuickFilterEditing.js +95 -0
  25. package/dist/shared/lib/entry-config.js +7 -7
  26. package/dist/shared/lib/integration-chip.js +10 -6
  27. package/dist/shared/lib/owners-header-tile.js +63 -0
  28. package/package.json +1 -1
@@ -0,0 +1,371 @@
1
+ import { jsx as e, jsxs as l, Fragment as E } from "react/jsx-runtime";
2
+ import { useQueryClient as M, useQuery as V } from "@tanstack/react-query";
3
+ import { ChevronRight as L, X as G, ArrowDownWideNarrow as H, ArrowUpNarrowWide as R, ChevronDown as U, Check as X } from "lucide-react";
4
+ import { useId as Y, useState as A, useEffect as z } from "react";
5
+ import { useNivaroClient as I } from "../../context.js";
6
+ import { get as K } from "../../lib/commands.js";
7
+ import { cn as v, titleCase as F } from "../../lib/utils.js";
8
+ import { Command as B, CommandInput as J, CommandList as Z, CommandEmpty as ee, CommandGroup as te, CommandItem as ae } from "../ui/command.js";
9
+ import { Popover as le, PopoverTrigger as re, PopoverContent as se } from "../ui/popover.js";
10
+ import { quickFilterProblems as ne, uniqueKey as ie, slugKey as O } from "./config.js";
11
+ import { guessLabelField as oe, pathLabel as _, useFacetMeta as ce } from "./facets.js";
12
+ import { QuickFilterFieldPicker as de, usedPathLabels as me } from "./QuickFilterFieldPicker.js";
13
+ const S = "h-7 w-full rounded-md border border-slate-200 bg-white px-2 text-[12px] text-slate-800 placeholder:text-slate-400 focus:border-nvr-cyan/60 focus:outline-none focus:ring-2 focus:ring-nvr-cyan/25 selection:bg-nvr-cyan/30 selection:text-slate-900 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-100 dark:placeholder:text-slate-500 dark:selection:text-white", u = "mb-1 block text-[11px] font-medium text-slate-600 dark:text-slate-300", D = "mt-1 text-[11px] leading-snug text-slate-500 dark:text-slate-400";
14
+ async function he(n, t, c) {
15
+ const r = await n.fetchQuery({
16
+ queryKey: ["cbv-collection-meta", c.target],
17
+ queryFn: () => t.request(K(`/collections/${c.target}`)).then((d) => d.data),
18
+ staleTime: 6e5
19
+ }).catch(() => null);
20
+ return { collection: c.target, label_field: oe(r), value_field: "id" };
21
+ }
22
+ function Q({
23
+ value: n,
24
+ onChange: t,
25
+ options: c,
26
+ blank: r,
27
+ ariaLabel: d,
28
+ loaded: o = !0,
29
+ missingHint: h
30
+ }) {
31
+ const [f, N] = A(!1), w = [
32
+ ...r !== void 0 ? [{ value: "", label: r }] : [],
33
+ ...c,
34
+ // A stored value the source no longer has stays visible rather than blank;
35
+ // what is wrong with it is said under the field, not cut off in here.
36
+ ...n && !c.some((i) => i.value === n) ? [{ value: n, label: F(n) }] : []
37
+ ], b = o && !!n && !c.some((i) => i.value === n), m = w.find((i) => i.value === n);
38
+ return /* @__PURE__ */ l(E, { children: [
39
+ /* @__PURE__ */ l(le, { open: f, onOpenChange: N, children: [
40
+ /* @__PURE__ */ e(re, { asChild: !0, children: /* @__PURE__ */ l(
41
+ "button",
42
+ {
43
+ type: "button",
44
+ role: "combobox",
45
+ "aria-expanded": f,
46
+ "aria-label": d,
47
+ className: "flex h-7 w-full min-w-0 items-center justify-between gap-1 rounded-md border border-slate-200 bg-white px-2 text-left text-[12px] text-slate-800 hover:border-slate-300 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/40 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-100 dark:hover:border-slate-600",
48
+ children: [
49
+ /* @__PURE__ */ e("span", { className: v("truncate", !n && "text-slate-500 dark:text-slate-400"), children: (m == null ? void 0 : m.label) ?? r ?? "Choose…" }),
50
+ /* @__PURE__ */ e(U, { "aria-hidden": !0, className: "h-3.5 w-3.5 shrink-0 text-slate-400" })
51
+ ]
52
+ }
53
+ ) }),
54
+ /* @__PURE__ */ e(
55
+ se,
56
+ {
57
+ align: "start",
58
+ sideOffset: 4,
59
+ className: "w-[min(16rem,calc(100vw-2rem))] rounded-lg border-slate-200 p-0 dark:border-slate-700 dark:bg-slate-900",
60
+ children: /* @__PURE__ */ l(B, { children: [
61
+ /* @__PURE__ */ e(J, { placeholder: "Search…", className: "h-8 text-[12px]" }),
62
+ /* @__PURE__ */ l(Z, { className: "max-h-60", children: [
63
+ /* @__PURE__ */ e(ee, { className: "py-3 text-center text-[12px] text-slate-500", children: "Nothing matches" }),
64
+ /* @__PURE__ */ e(te, { children: w.map((i) => /* @__PURE__ */ l(
65
+ ae,
66
+ {
67
+ value: `${i.label} ${i.value}`,
68
+ onSelect: () => {
69
+ t(i.value), N(!1);
70
+ },
71
+ className: "text-[12px]",
72
+ children: [
73
+ /* @__PURE__ */ e(
74
+ X,
75
+ {
76
+ "aria-hidden": !0,
77
+ className: v(
78
+ "mr-1.5 h-3 w-3",
79
+ i.value === n ? "opacity-100" : "opacity-0"
80
+ )
81
+ }
82
+ ),
83
+ i.label
84
+ ]
85
+ },
86
+ i.value || "__blank__"
87
+ )) })
88
+ ] })
89
+ ] })
90
+ }
91
+ )
92
+ ] }),
93
+ b && h && /* @__PURE__ */ e("p", { className: "mt-1 text-[11px] leading-snug text-amber-800 dark:text-amber-300", children: h })
94
+ ] });
95
+ }
96
+ function C({
97
+ collection: n,
98
+ ...t
99
+ }) {
100
+ var d;
101
+ const r = (((d = ce(n || null).data) == null ? void 0 : d.fields) ?? []).filter((o) => !o.field.startsWith("__")).map((o) => ({ value: o.field, label: o.field === "id" ? "ID" : F(o.field) }));
102
+ return /* @__PURE__ */ e(
103
+ Q,
104
+ {
105
+ ...t,
106
+ options: r,
107
+ loaded: r.length > 0,
108
+ missingHint: "Not a column of the options source."
109
+ }
110
+ );
111
+ }
112
+ function pe({ value: n, onChange: t }) {
113
+ const c = I(), { data: r = [], isSuccess: d } = V({
114
+ queryKey: ["nvr-collections-registry"],
115
+ queryFn: () => c.request(
116
+ K("/collections")
117
+ ).then((o) => (o.data ?? []).filter((h) => !h.collection.startsWith("nivaro_"))),
118
+ staleTime: 5 * 6e4
119
+ });
120
+ return /* @__PURE__ */ e(
121
+ Q,
122
+ {
123
+ value: n,
124
+ onChange: t,
125
+ ariaLabel: "Options from",
126
+ blank: n ? void 0 : "Choose…",
127
+ loaded: d,
128
+ missingHint: "This collection isn’t registered — its options may not load.",
129
+ options: r.map((o) => {
130
+ var h;
131
+ return {
132
+ value: o.collection,
133
+ label: ((h = o.display_name) == null ? void 0 : h.trim()) || F(o.collection)
134
+ };
135
+ })
136
+ }
137
+ );
138
+ }
139
+ function Fe({
140
+ collection: n,
141
+ value: t,
142
+ all: c,
143
+ onChange: r,
144
+ isNew: d = !1,
145
+ onPickingChange: o,
146
+ footer: h,
147
+ className: f
148
+ }) {
149
+ var P, q;
150
+ const N = M(), w = I(), b = Y(), [m, i] = A(null);
151
+ z(() => o == null ? void 0 : o(m !== null), [m]);
152
+ const $ = ne(t, c), p = (P = t.or_paths) != null && P.length ? t.or_paths : (q = t.path) != null && q.length ? [t.path] : [], T = async (a) => {
153
+ var k;
154
+ const s = m;
155
+ if (i(null), s === "path" || s === 0) {
156
+ const j = a.target === t.collection ? {} : await he(N, w, a);
157
+ (k = t.or_paths) != null && k.length ? r({ or_paths: [a.path, ...t.or_paths.slice(1)], path: a.path, ...j }) : r({ path: a.path, ...j });
158
+ return;
159
+ }
160
+ if (typeof s == "number") {
161
+ const y = [...p];
162
+ y[s] = a.path, r({ or_paths: y });
163
+ }
164
+ }, W = (a) => {
165
+ const s = p.filter((k, y) => y !== a);
166
+ s.length <= 1 ? r({ or_paths: void 0, path: s[0] ?? [] }) : r({ or_paths: s, path: s[0] });
167
+ };
168
+ if (m !== null) {
169
+ const a = typeof m == "number" ? p[m] : p[0];
170
+ return /* @__PURE__ */ e("div", { className: v(f, "p-0"), children: /* @__PURE__ */ e(
171
+ de,
172
+ {
173
+ rootCollection: n,
174
+ initialPath: a,
175
+ currentPath: a,
176
+ used: me(c.filter((s) => s !== t)),
177
+ onPick: (s) => void T(s),
178
+ onCancel: () => i(null)
179
+ }
180
+ ) });
181
+ }
182
+ const x = (t.sort ?? "").startsWith("-"), g = (t.sort ?? "").replace(/^-/, "");
183
+ return /* @__PURE__ */ l("div", { className: v("space-y-3", f), children: [
184
+ $.length > 0 && /* @__PURE__ */ l(
185
+ "p",
186
+ {
187
+ role: "status",
188
+ className: "rounded-md bg-amber-50 px-2 py-1.5 text-[11.5px] leading-snug text-amber-800 dark:bg-amber-500/10 dark:text-amber-200",
189
+ children: [
190
+ "This filter ",
191
+ $.join(", "),
192
+ " before it can be saved."
193
+ ]
194
+ }
195
+ ),
196
+ /* @__PURE__ */ l("div", { children: [
197
+ /* @__PURE__ */ e("label", { htmlFor: `${b}-name`, className: u, children: "Name on the bar" }),
198
+ /* @__PURE__ */ e(
199
+ "input",
200
+ {
201
+ id: `${b}-name`,
202
+ "data-qf-name": "",
203
+ value: t.label ?? "",
204
+ placeholder: "Funding Year",
205
+ onChange: (a) => {
206
+ const s = a.target.value;
207
+ r(
208
+ d ? {
209
+ label: s,
210
+ key: ie(
211
+ O(s),
212
+ c.filter((k) => k !== t)
213
+ )
214
+ } : { label: s }
215
+ );
216
+ },
217
+ className: S
218
+ }
219
+ )
220
+ ] }),
221
+ /* @__PURE__ */ l("div", { children: [
222
+ /* @__PURE__ */ e("span", { className: u, children: "Filters by" }),
223
+ p.length === 0 ? /* @__PURE__ */ l(
224
+ "button",
225
+ {
226
+ type: "button",
227
+ onClick: () => i("path"),
228
+ className: "flex h-7 w-full items-center justify-between rounded-md border border-dashed border-slate-300 px-2 text-[12px] text-slate-500 hover:border-nvr-cyan/60 hover:text-slate-800 dark:border-slate-600 dark:text-slate-400 dark:hover:text-slate-100",
229
+ children: [
230
+ "Pick a field",
231
+ /* @__PURE__ */ e(L, { "aria-hidden": !0, className: "h-3.5 w-3.5" })
232
+ ]
233
+ }
234
+ ) : /* @__PURE__ */ e("ul", { className: "space-y-1", children: p.map((a, s) => (
235
+ // biome-ignore lint/suspicious/noArrayIndexKey: the same path may sit in two slots while being edited
236
+ /* @__PURE__ */ l("li", { className: "flex items-center gap-1", children: [
237
+ s > 0 && /* @__PURE__ */ e("span", { className: "w-5 shrink-0 text-center text-[11px] text-slate-500 dark:text-slate-400", children: "or" }),
238
+ /* @__PURE__ */ l(
239
+ "button",
240
+ {
241
+ type: "button",
242
+ onClick: () => i(s === 0 ? "path" : s),
243
+ "aria-label": `Change field ${_(a)}`,
244
+ className: "flex h-7 min-w-0 flex-1 items-center justify-between gap-2 rounded-md border border-slate-200 bg-white px-2 text-left text-[12px] text-slate-800 hover:border-nvr-cyan/60 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-100",
245
+ children: [
246
+ /* @__PURE__ */ e("span", { className: "truncate", children: _(a) }),
247
+ /* @__PURE__ */ e("span", { className: "shrink-0 text-[11px] text-slate-500 dark:text-slate-400", children: "Change" })
248
+ ]
249
+ }
250
+ ),
251
+ p.length > 1 && /* @__PURE__ */ e(
252
+ "button",
253
+ {
254
+ type: "button",
255
+ onClick: () => W(s),
256
+ "aria-label": `Stop matching ${_(a)}`,
257
+ className: "flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-slate-400 hover:bg-slate-100 hover:text-red-600 dark:hover:bg-slate-800 dark:hover:text-red-400",
258
+ children: /* @__PURE__ */ e(G, { className: "h-3.5 w-3.5" })
259
+ }
260
+ )
261
+ ] }, `${s}-${a.join(".")}`)
262
+ )) })
263
+ ] }),
264
+ /* @__PURE__ */ l("div", { className: "grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)] gap-2", children: [
265
+ /* @__PURE__ */ l("div", { children: [
266
+ /* @__PURE__ */ e("span", { className: u, children: "Options show" }),
267
+ /* @__PURE__ */ e(
268
+ C,
269
+ {
270
+ collection: t.collection ?? "",
271
+ value: t.label_field ?? "",
272
+ onChange: (a) => r({ label_field: a }),
273
+ ariaLabel: "Column the options show"
274
+ }
275
+ )
276
+ ] }),
277
+ /* @__PURE__ */ l("div", { children: [
278
+ /* @__PURE__ */ e("span", { className: u, children: "Order" }),
279
+ /* @__PURE__ */ l("div", { className: "flex gap-1", children: [
280
+ /* @__PURE__ */ e("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ e(
281
+ C,
282
+ {
283
+ collection: t.collection ?? "",
284
+ value: g,
285
+ onChange: (a) => r({ sort: a ? x ? `-${a}` : a : void 0 }),
286
+ blank: "As stored",
287
+ ariaLabel: "Option order"
288
+ }
289
+ ) }),
290
+ /* @__PURE__ */ e(
291
+ "button",
292
+ {
293
+ type: "button",
294
+ disabled: !g,
295
+ onClick: () => r({ sort: x ? g : `-${g}` }),
296
+ "aria-label": x ? "Descending — switch to ascending" : "Ascending — switch to descending",
297
+ "data-tip": g ? x ? "Descending" : "Ascending" : void 0,
298
+ className: "flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-slate-200 text-slate-600 hover:bg-slate-50 disabled:opacity-40 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800",
299
+ children: x ? /* @__PURE__ */ e(H, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ e(R, { className: "h-3.5 w-3.5" })
300
+ }
301
+ )
302
+ ] })
303
+ ] })
304
+ ] }),
305
+ /* @__PURE__ */ l("details", { className: "group", children: [
306
+ /* @__PURE__ */ l("summary", { className: "inline-flex cursor-pointer list-none items-center gap-1 rounded text-[11.5px] font-medium text-slate-600 hover:text-slate-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/50 dark:text-slate-300 dark:hover:text-white [&::-webkit-details-marker]:hidden", children: [
307
+ /* @__PURE__ */ e(L, { "aria-hidden": !0, className: "h-3 w-3 transition-transform group-open:rotate-90" }),
308
+ "More options"
309
+ ] }),
310
+ /* @__PURE__ */ l("div", { className: "mt-2 space-y-3", children: [
311
+ /* @__PURE__ */ l("div", { className: "grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)] gap-2", children: [
312
+ /* @__PURE__ */ l("div", { children: [
313
+ /* @__PURE__ */ e("span", { className: u, children: "Options from" }),
314
+ /* @__PURE__ */ e(
315
+ pe,
316
+ {
317
+ value: t.collection ?? "",
318
+ onChange: (a) => r({ collection: a })
319
+ }
320
+ )
321
+ ] }),
322
+ /* @__PURE__ */ l("div", { children: [
323
+ /* @__PURE__ */ e("span", { className: u, children: "Value column" }),
324
+ /* @__PURE__ */ e(
325
+ C,
326
+ {
327
+ collection: t.collection ?? "",
328
+ value: t.value_field && t.value_field !== "id" ? t.value_field : "",
329
+ onChange: (a) => r({ value_field: a || void 0 }),
330
+ blank: "ID (default)",
331
+ ariaLabel: "Value column"
332
+ }
333
+ )
334
+ ] })
335
+ ] }),
336
+ /* @__PURE__ */ l("div", { children: [
337
+ /* @__PURE__ */ e("label", { htmlFor: `${b}-key`, className: u, children: "Key" }),
338
+ /* @__PURE__ */ e(
339
+ "input",
340
+ {
341
+ id: `${b}-key`,
342
+ value: t.key ?? "",
343
+ placeholder: "fy",
344
+ onChange: (a) => r({ key: O(a.target.value) }),
345
+ className: v(S, "font-mono")
346
+ }
347
+ ),
348
+ /* @__PURE__ */ e("p", { className: D, children: d ? "Follows the name until you change it." : "People’s picks and default filters follow the key — changing it clears them." })
349
+ ] }),
350
+ p.length > 0 && /* @__PURE__ */ l("div", { children: [
351
+ /* @__PURE__ */ e(
352
+ "button",
353
+ {
354
+ type: "button",
355
+ onClick: () => i(p.length),
356
+ className: "text-[11.5px] font-medium text-[#0284a8] hover:underline dark:text-nvr-cyan",
357
+ children: "Also match another field"
358
+ }
359
+ ),
360
+ /* @__PURE__ */ e("p", { className: D, children: "For a value records reach two ways — the filter matches either one." })
361
+ ] })
362
+ ] })
363
+ ] }),
364
+ h
365
+ ] });
366
+ }
367
+ export {
368
+ Fe as QuickFilterForm,
369
+ he as facetDefaults,
370
+ S as qfInputCls
371
+ };
@@ -0,0 +1,63 @@
1
+ const h = (e) => e.trim().toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
2
+ function f(e, n) {
3
+ const t = new Set(n.map((i) => (i.key ?? "").trim())), l = e || "filter";
4
+ if (!t.has(l)) return l;
5
+ for (let i = 2; i < 1e3; i++) if (!t.has(`${l}_${i}`)) return `${l}_${i}`;
6
+ return `${l}_${Date.now()}`;
7
+ }
8
+ const c = (e) => {
9
+ var n, t;
10
+ return (((n = e.path) == null ? void 0 : n.length) ?? 0) > 0 || !!((t = e.or_paths) != null && t.length) && e.or_paths.every((l) => l.length > 0);
11
+ };
12
+ function u(e, n) {
13
+ var i, r, o;
14
+ const t = [], l = (e.key ?? "").trim();
15
+ return l ? n.filter((s) => (s.key ?? "").trim() === l).length > 1 && t.push("duplicate key") : t.push("needs a key"), (i = e.label) != null && i.trim() || t.push("needs a name"), c(e) || t.push("needs a field"), (r = e.collection) != null && r.trim() || t.push("needs an options source"), (o = e.label_field) != null && o.trim() || t.push("needs a column to show"), t;
16
+ }
17
+ function p(e) {
18
+ var t, l;
19
+ const n = [];
20
+ for (const i of e ?? []) {
21
+ if (!i || typeof i != "object") continue;
22
+ const r = {
23
+ ...i,
24
+ key: (i.key ?? "").trim(),
25
+ label: (i.label ?? "").trim(),
26
+ collection: (i.collection ?? "").trim(),
27
+ label_field: (i.label_field ?? "").trim(),
28
+ path: Array.isArray(i.path) ? i.path.filter(Boolean) : []
29
+ };
30
+ if ((t = r.value_field) != null && t.trim() || delete r.value_field, (l = r.sort) != null && l.trim() || delete r.sort, r.or_paths) {
31
+ const o = r.or_paths.filter((s) => Array.isArray(s) && s.length > 0);
32
+ o.length > 0 ? r.or_paths = o : delete r.or_paths;
33
+ }
34
+ u(r, [r]).length > 0 || n.push(r);
35
+ }
36
+ return n;
37
+ }
38
+ function y(e, n) {
39
+ const t = { ...e ?? {} };
40
+ return n.length > 0 ? t.quick_filters = n : delete t.quick_filters, Object.keys(t).length > 0 ? t : null;
41
+ }
42
+ function _(e, n) {
43
+ return JSON.stringify(e) === JSON.stringify(n);
44
+ }
45
+ const a = (e) => {
46
+ var n;
47
+ return JSON.stringify([(n = e.or_paths) != null && n.length ? e.or_paths : e.path, e.collection, e.value_field || "id"]);
48
+ };
49
+ function m(e, n, t) {
50
+ const l = new Map(n.map((o) => [o.key, a(o)])), i = new Map(t.map((o) => [o.key, a(o)])), r = {};
51
+ for (const [o, s] of Object.entries(e))
52
+ l.has(o) && (!i.has(o) || i.get(o) !== l.get(o)) || (r[o] = s);
53
+ return r;
54
+ }
55
+ export {
56
+ p as cleanQuickFilters,
57
+ y as mergeQuickFilters,
58
+ m as pruneQuickSelection,
59
+ u as quickFilterProblems,
60
+ _ as quickFiltersEqual,
61
+ h as slugKey,
62
+ f as uniqueKey
63
+ };
@@ -0,0 +1,55 @@
1
+ import { useQuery as s } from "@tanstack/react-query";
2
+ import { useNivaroClient as a } from "../../context.js";
3
+ import { get as d } from "../../lib/commands.js";
4
+ import { titleCase as _ } from "../../lib/utils.js";
5
+ function j(n, t) {
6
+ if (!n) return [];
7
+ const o = n.relations ?? [], f = [], l = /* @__PURE__ */ new Set();
8
+ for (const e of o)
9
+ if (e.many_collection === t && e.one_collection && e.many_field) {
10
+ if (l.has(e.many_field) || e.many_field.startsWith("__")) continue;
11
+ l.add(e.many_field), f.push({ field: e.many_field, kind: "one", target: e.one_collection, junction: !1 });
12
+ }
13
+ for (const e of o) {
14
+ if (e.one_collection !== t || !e.one_field || l.has(e.one_field) || e.one_field.startsWith("__")) continue;
15
+ let i = e.many_collection;
16
+ if (e.junction_field) {
17
+ const c = o.find(
18
+ (r) => r.many_collection === e.many_collection && r.many_field === e.junction_field && r.one_collection
19
+ );
20
+ c != null && c.one_collection && (i = c.one_collection);
21
+ }
22
+ l.add(e.one_field), f.push({ field: e.one_field, kind: "many", target: i, junction: !!e.junction_field });
23
+ }
24
+ return f.sort((e, i) => e.field.localeCompare(i.field));
25
+ }
26
+ const u = ["name", "title", "label", "display_name", "year", "code", "type"];
27
+ function b(n) {
28
+ var e;
29
+ const t = ((n == null ? void 0 : n.fields) ?? []).filter((i) => !i.field.startsWith("__")), o = new Set(t.map((i) => i.field)), f = /\{\{\s*([A-Za-z_][A-Za-z0-9_]*)\s*\}\}/.exec((n == null ? void 0 : n.display_template) ?? "");
30
+ if (f && o.has(f[1])) return f[1];
31
+ for (const i of u) if (o.has(i)) return i;
32
+ const l = t.find(
33
+ (i) => i.field !== "id" && /^(string|text|varchar|nvarchar)/i.test(i.type ?? "")
34
+ );
35
+ return (l == null ? void 0 : l.field) ?? (o.has("id") ? "id" : ((e = t[0]) == null ? void 0 : e.field) ?? "");
36
+ }
37
+ function A(n) {
38
+ return (n ?? []).map((t) => _(t)).join(" › ");
39
+ }
40
+ function g(n) {
41
+ const t = a();
42
+ return s({
43
+ queryKey: ["cbv-collection-meta", n],
44
+ queryFn: () => t.request(d(`/collections/${n}`)).then((o) => o.data),
45
+ enabled: !!n,
46
+ staleTime: 10 * 6e4,
47
+ retry: !1
48
+ });
49
+ }
50
+ export {
51
+ j as facetHops,
52
+ b as guessLabelField,
53
+ A as pathLabel,
54
+ g as useFacetMeta
55
+ };
@@ -0,0 +1,95 @@
1
+ import { useQueryClient as B } from "@tanstack/react-query";
2
+ import { useState as d, useRef as F, useEffect as G, useCallback as x } from "react";
3
+ import { useNivaroClient as H } from "../../context.js";
4
+ import { get as J, patch as L } from "../../lib/commands.js";
5
+ import { useUnsavedWork as M } from "../../lib/unsaved-work.js";
6
+ import { quickFiltersEqual as V, quickFilterProblems as X, cleanQuickFilters as Y, mergeQuickFilters as _ } from "./config.js";
7
+ let Z = 0;
8
+ const T = () => `qf${++Z}`;
9
+ function oe({
10
+ collection: m,
11
+ filters: b,
12
+ onApplied: y
13
+ }) {
14
+ const u = B(), q = H(), [C, k] = d(!1), [g, a] = d([]), [h, l] = d("idle"), [j, Q] = d(null), [D, f] = d(null), [N, w] = d(!1), p = F([]), v = F(null);
15
+ G(
16
+ () => () => {
17
+ v.current && window.clearTimeout(v.current);
18
+ },
19
+ []
20
+ );
21
+ const I = g.map((e) => e.def), E = C && !V(I, p.current), $ = g.filter((e) => X(e.def, I).length > 0).length;
22
+ M(E, "Quick filter changes");
23
+ const O = x(
24
+ (e = {}) => {
25
+ p.current = b, a(b.map((r) => ({ id: T(), def: { ...r }, isNew: !1 }))), k(!0), Q(null), l("idle"), f(null), w(!!e.adding || b.length === 0);
26
+ },
27
+ [b]
28
+ ), S = x(() => {
29
+ k(!1), Q(null), f(null), w(!1), h === "error" && l("idle");
30
+ }, [h]), K = (e) => {
31
+ const r = T();
32
+ a((t) => [...t, { id: r, def: e, isNew: !0 }]), w(!1), f(r);
33
+ }, P = (e, r) => a(
34
+ (t) => t.map((n) => {
35
+ if (n.id !== e) return n;
36
+ const o = { ...n.def, ...r };
37
+ for (const c of Object.keys(r))
38
+ r[c] === void 0 && delete o[c];
39
+ return { ...n, def: o };
40
+ })
41
+ ), R = (e) => {
42
+ a((r) => r.filter((t) => t.id !== e)), D === e && f(null);
43
+ }, U = (e, r) => a((t) => {
44
+ const n = t.findIndex((i) => i.id === e), o = n + r;
45
+ if (n < 0 || o < 0 || o >= t.length) return t;
46
+ const c = [...t], [s] = c.splice(n, 1);
47
+ return c.splice(o, 0, s), c;
48
+ }), W = (e, r) => a((t) => {
49
+ const n = t.findIndex((i) => i.id === e), o = t.findIndex((i) => i.id === r);
50
+ if (n < 0 || o < 0 || n === o) return t;
51
+ const c = [...t], [s] = c.splice(n, 1);
52
+ return c.splice(o, 0, s), c;
53
+ }), z = x(async () => {
54
+ var c;
55
+ const e = Y(g.map((s) => s.def)), r = p.current, t = ["cbv-collection-meta", m], n = u.getQueryData(t);
56
+ u.setQueryData(
57
+ t,
58
+ (s) => s && { ...s, browser_config: _(s.browser_config, e) }
59
+ ), k(!1), f(null), w(!1), Q(null), l("saving"), v.current && window.clearTimeout(v.current);
60
+ const o = y == null ? void 0 : y(e, r);
61
+ try {
62
+ const s = await q.request(J(`/collections/${m}`)), i = _(((c = s.data) == null ? void 0 : c.browser_config) ?? null, e);
63
+ await q.request(L(`/collections/${m}`, { browser_config: i })), p.current = e, u.setQueryData(t, {
64
+ ...s.data ?? n ?? {},
65
+ browser_config: i
66
+ }), u.invalidateQueries({ queryKey: ["collection-meta", m] }), l("saved"), v.current = window.setTimeout(() => l("idle"), 3e3);
67
+ } catch (s) {
68
+ u.setQueryData(t, n), o == null || o(), k(!0), l("error"), Q(s);
69
+ }
70
+ }, [q, m, g, y, u]);
71
+ return {
72
+ editing: C,
73
+ draft: g,
74
+ defs: I,
75
+ dirty: E,
76
+ problemCount: $,
77
+ status: h,
78
+ error: j,
79
+ openId: D,
80
+ setOpenId: f,
81
+ adding: N,
82
+ setAdding: w,
83
+ start: O,
84
+ cancel: S,
85
+ add: K,
86
+ update: P,
87
+ remove: R,
88
+ move: U,
89
+ reorder: W,
90
+ save: z
91
+ };
92
+ }
93
+ export {
94
+ oe as useQuickFilterEditing
95
+ };
@@ -1,4 +1,4 @@
1
- const u = 3, p = 50, E = 16, A = 20, g = 200, a = [
1
+ const u = 3, p = 50, E = 16, A = 20, g = 200, c = [
2
2
  "slate",
3
3
  "blue",
4
4
  "cyan",
@@ -13,7 +13,7 @@ function f(e) {
13
13
  const t = typeof e.name == "string" ? e.name.replace(/\s+/g, " ").trim().slice(0, 60) : "", n = typeof e.id == "string" ? e.id.replace(/[^A-Za-z0-9_-]/g, "").slice(0, 40) : "";
14
14
  if (!t || !n) return null;
15
15
  const r = (Array.isArray(e.parts) ? e.parts : []).filter(
16
- (c) => l.includes(c)
16
+ (a) => l.includes(a)
17
17
  ), s = { id: n, name: t, parts: [...new Set(r)] };
18
18
  return (e.col_span === null || typeof e.col_span == "number") && (s.col_span = e.col_span === null ? null : Math.min(12, Math.max(1, Math.round(e.col_span)))), o(e.overrides) && (s.overrides = e.overrides), (e.lock_conditions === null || typeof e.lock_conditions == "string") && (s.lock_conditions = e.lock_conditions), s;
19
19
  }
@@ -27,7 +27,7 @@ function d(e) {
27
27
  }
28
28
  if (!o(t)) return null;
29
29
  const n = {};
30
- if (t.focus_first === !0 && (n.focus_first = !0), t.enter_next === !0 && (n.enter_next = !0), t.adaptive === !0 && (n.adaptive = !0), t.glossary === !1 && (n.glossary = !1), t.density === "compact" && (n.density = "compact"), t.tour === !0 && (n.tour = !0), typeof t.adaptive_threshold == "number" && Number.isFinite(t.adaptive_threshold)) {
30
+ if (t.focus_first === !0 && (n.focus_first = !0), t.enter_next === !0 && (n.enter_next = !0), t.adaptive === !0 && (n.adaptive = !0), t.glossary === !1 && (n.glossary = !1), t.density === "compact" && (n.density = "compact"), t.tour === !0 && (n.tour = !0), t.external_requests === !1 && (n.external_requests = !1), typeof t.adaptive_threshold == "number" && Number.isFinite(t.adaptive_threshold)) {
31
31
  const r = Math.min(50, Math.max(1, Math.round(t.adaptive_threshold)));
32
32
  r !== 3 && (n.adaptive_threshold = r);
33
33
  }
@@ -38,13 +38,13 @@ function d(e) {
38
38
  r.length && (n.tab_order = r);
39
39
  }
40
40
  if (o(t.badge)) {
41
- const r = typeof t.badge.tag == "string" ? t.badge.tag.replace(/\s+/g, " ").trim().slice(0, 16) : "", s = a.includes(t.badge.color) ? t.badge.color : "slate";
41
+ const r = typeof t.badge.tag == "string" ? t.badge.tag.replace(/\s+/g, " ").trim().slice(0, 16) : "", s = c.includes(t.badge.color) ? t.badge.color : "slate";
42
42
  r && (n.badge = { tag: r, color: s });
43
43
  }
44
44
  if (Array.isArray(t.presets)) {
45
45
  const r = /* @__PURE__ */ new Set(), s = [];
46
- for (const c of t.presets) {
47
- const i = f(c);
46
+ for (const a of t.presets) {
47
+ const i = f(a);
48
48
  if (i && !r.has(i.id) && (r.add(i.id), s.push(i)), s.length >= 20) break;
49
49
  }
50
50
  s.length && (n.presets = s);
@@ -58,7 +58,7 @@ function h(e, t) {
58
58
  return e < (t.adaptive_threshold ?? 3);
59
59
  }
60
60
  export {
61
- a as BADGE_COLORS,
61
+ c as BADGE_COLORS,
62
62
  E as ENTRY_BADGE_TAG_MAX,
63
63
  A as ENTRY_PRESETS_MAX,
64
64
  g as ENTRY_TAB_ORDER_MAX,
@@ -1,13 +1,13 @@
1
1
  const r = (e) => e === "accepted" ? "ok" : e === "failed" || e === "rejected" ? "attention" : e === "pending" ? "pending" : "neutral";
2
- function p(e, s, i = () => "") {
3
- const n = [], o = /* @__PURE__ */ new Set();
2
+ function l(e, o, i = () => "") {
3
+ const n = [], s = /* @__PURE__ */ new Set();
4
4
  for (const t of e) {
5
5
  const a = t.tone === "positive" ? "ok" : t.tone === "danger" ? "attention" : t.outcome === "pending" ? "pending" : "neutral";
6
- n.push({ name: t.api, status: a, tip: `${t.api} · ${t.text}` }), o.add(t.api.toLowerCase());
6
+ n.push({ name: t.api, status: a, tip: `${t.api} · ${t.text}` }), s.add(t.api.toLowerCase());
7
7
  }
8
- for (const t of s) {
8
+ for (const t of o) {
9
9
  const a = t.external_api_name ?? (t.external_api != null ? `#${t.external_api}` : "External");
10
- o.has(a.toLowerCase()) || (o.add(a.toLowerCase()), n.push({
10
+ s.has(a.toLowerCase()) || (s.add(a.toLowerCase()), n.push({
11
11
  name: a,
12
12
  status: r(t.status),
13
13
  tip: `${a} · ${t.status} · ${i(t.updated_at ?? t.created_at)}${t.last_error ? ` — ${t.last_error.slice(0, 120)}` : ""}`
@@ -20,6 +20,10 @@ function p(e, s, i = () => "") {
20
20
  pending: n.filter((t) => t.status === "pending").length
21
21
  };
22
22
  }
23
+ function u(e) {
24
+ return e.layoutOn ? e.obligations === null || e.submissions === null ? null : e.partnerIntegration !== !1 || e.obligations > 0 || e.submissions > 0 : !1;
25
+ }
23
26
  export {
24
- p as integrationChipSummary
27
+ u as externalRequestsShown,
28
+ l as integrationChipSummary
25
29
  };