@nivaro/react 0.3.9 → 0.3.11
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/components/fields/FileField.js +20 -19
- package/dist/full.css +1 -1
- package/dist/hooks/useNivaroForm.js +129 -126
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +103 -4
- package/dist/index.js +512 -501
- package/dist/shared/components/CollectionBrowserView.js +1632 -1564
- package/dist/shared/components/ConformanceView.js +36 -35
- package/dist/shared/components/ForceReloadBanner.js +58 -34
- package/dist/shared/components/ItemEditForm.js +4386 -4142
- package/dist/shared/components/JsonMapEditor.js +18 -17
- package/dist/shared/components/MatrixEditor.js +8 -7
- package/dist/shared/components/MyWorkView.js +32 -31
- package/dist/shared/components/PageRenderer.js +527 -479
- package/dist/shared/components/QueryStatStrip.js +74 -70
- package/dist/shared/components/RecordGridEditor.js +76 -75
- package/dist/shared/components/ReportView.js +818 -827
- package/dist/shared/components/SheetHeaderBody.js +16 -14
- package/dist/shared/components/ai/AiMemorySuggestions.js +15 -14
- package/dist/shared/components/ai/AskPanel.js +55 -54
- package/dist/shared/components/bulk/BulkActionButtons.js +30 -29
- package/dist/shared/components/bulk/PushBulkButtons.js +57 -56
- package/dist/shared/components/chat/SlashCommands.js +30 -29
- package/dist/shared/components/chat/chat-outbox.js +76 -75
- package/dist/shared/components/help-videos/recorder/useLeaveWarning.js +6 -5
- package/dist/shared/components/integrations/console/SignalCard.js +124 -123
- package/dist/shared/components/integrations/console/SnoozeMenu.js +24 -23
- package/dist/shared/components/item-edit/CatalogPickerField.js +1029 -933
- package/dist/shared/components/item-edit/CloneDialog.js +85 -78
- package/dist/shared/components/item-edit/FieldRenderer.js +161 -156
- package/dist/shared/components/item-edit/FieldRow.js +20 -19
- package/dist/shared/components/item-edit/FilePickerField.js +52 -40
- package/dist/shared/components/item-edit/GroupSection.js +221 -221
- package/dist/shared/components/item-edit/InlineGridField.js +41 -41
- package/dist/shared/components/item-edit/InlineTableField.js +2287 -2275
- package/dist/shared/components/item-edit/M2MCombobox.js +46 -44
- package/dist/shared/components/item-edit/MembershipSetField.js +24 -23
- package/dist/shared/components/item-edit/NestedRelationEditor.js +11 -11
- package/dist/shared/components/item-edit/QuickCreateButton.js +8 -7
- package/dist/shared/components/item-edit/QuickPicker.js +263 -216
- package/dist/shared/components/item-edit/RecordLiveSync.js +101 -100
- package/dist/shared/components/item-edit/RelationCombobox.js +285 -245
- package/dist/shared/components/item-edit/RichTextEditorImpl.js +42 -32
- package/dist/shared/components/item-edit/RowHistorySheet.js +130 -134
- package/dist/shared/components/item-edit/SummaryPanel.js +305 -279
- package/dist/shared/components/item-edit/helpers.js +133 -134
- package/dist/shared/components/item-edit/line-qty.js +57 -0
- package/dist/shared/components/item-edit/option-disambiguate.js +53 -0
- package/dist/shared/components/item-edit/staged-links.js +86 -0
- package/dist/shared/components/layout-editor/LayoutEditor.js +275 -274
- package/dist/shared/components/layout-editor/editors/cascade-rule-row.js +18 -17
- package/dist/shared/components/layout-editor/inspector/HelpTab.js +37 -36
- package/dist/shared/components/layout-editor/matrix/FieldStateMatrix.js +50 -49
- package/dist/shared/components/panels/AddendumLinesDiff.js +87 -90
- package/dist/shared/components/panels/CommentPanel.js +350 -315
- package/dist/shared/components/panels/ItemLockBanner.js +297 -230
- package/dist/shared/components/panels/PipelinePanel.js +719 -701
- package/dist/shared/components/profile/AiMemoryCard.js +15 -14
- package/dist/shared/components/profile/PersonAdminTools.js +70 -67
- package/dist/shared/components/queue/QueueItemSheet.js +36 -35
- package/dist/shared/components/queue/QueueQuickFilters.js +43 -41
- package/dist/shared/components/queue/QueueWorklist.js +1026 -957
- package/dist/shared/components/widgets/ReviewListWidget.js +99 -93
- package/dist/shared/lib/client-version.js +63 -0
- package/dist/shared/lib/force-reload.js +36 -0
- package/dist/shared/lib/load-error.js +11 -10
- package/dist/shared/lib/obligation-banner.js +14 -13
- package/dist/shared/lib/obligation-reason-text.js +13 -0
- package/dist/shared/lib/presence-live.js +54 -35
- package/dist/shared/lib/query-filter-seed.js +34 -11
- package/dist/shared/lib/record-outbox.js +76 -75
- package/dist/shared/lib/safe-error.js +39 -0
- package/dist/shared/lib/sanitize-html.js +24 -15
- package/dist/shared/lib/server-clock.js +11 -7
- package/dist/shared/lib/sheet-def.js +38 -22
- package/dist/shared/lib/unique-options.js +10 -0
- package/dist/shared/lib/unsaved-work.js +62 -0
- package/dist/shared/lib/utils.js +57 -43
- package/dist/shared/lib/validation-rules.js +58 -34
- package/package.json +1 -1
|
@@ -7,9 +7,9 @@ import { parseAllowedCollections as Ie } from "../../lib/allowed-collections.js"
|
|
|
7
7
|
import { get as C } from "../../lib/commands.js";
|
|
8
8
|
import { useRecordReader as Ae } from "../../lib/record-loader.js";
|
|
9
9
|
import { useOnlineUsers as he } from "../../lib/use-online-users.js";
|
|
10
|
-
import { cn as Q, userOptionFilter as
|
|
11
|
-
import { UserAvatar as
|
|
12
|
-
import { Command as xe, CommandInput as
|
|
10
|
+
import { cn as Q, userOptionFilter as be } from "../../lib/utils.js";
|
|
11
|
+
import { UserAvatar as ye } from "../UserAvatar.js";
|
|
12
|
+
import { Command as xe, CommandInput as ve, CommandList as ge, CommandEmpty as ke, CommandGroup as we, CommandItem as Ne } from "../ui/command.js";
|
|
13
13
|
import { Popover as Se, PopoverTrigger as _e, PopoverContent as Ce } from "../ui/popover.js";
|
|
14
14
|
import { applyDisplayTemplate as qe } from "./helpers.js";
|
|
15
15
|
import { useM2MStaging as Le } from "./M2MStagingContext.js";
|
|
@@ -38,31 +38,31 @@ function tt({
|
|
|
38
38
|
parentId: o,
|
|
39
39
|
allRelations: N,
|
|
40
40
|
extraFilter: h,
|
|
41
|
-
optionSort:
|
|
41
|
+
optionSort: b,
|
|
42
42
|
requiredParent: K,
|
|
43
43
|
onCountChange: J,
|
|
44
44
|
drilldown: D
|
|
45
45
|
}) {
|
|
46
|
-
const
|
|
46
|
+
const y = fe(), W = $e(), t = Le(), [P, q] = ne(!1), [L, T] = ne(""), le = N.find(
|
|
47
47
|
(e) => e.many_collection === s.many_collection && e.many_field === s.junction_field && e.id !== s.id
|
|
48
|
-
), r = Te(le), x = s.junction_field ?? "",
|
|
48
|
+
), r = Te(le), x = s.junction_field ?? "", R = s.many_field ?? "", d = s.one_field ?? `${s.many_collection}.${x}`, { data: a } = w({
|
|
49
49
|
queryKey: ["col-meta", r],
|
|
50
|
-
queryFn: () =>
|
|
50
|
+
queryFn: () => y.request(C(`/collections/${r}`)).then((e) => e.data),
|
|
51
51
|
enabled: !!r,
|
|
52
52
|
staleTime: 3e5,
|
|
53
53
|
retry: !1
|
|
54
54
|
}), { data: X = [] } = w({
|
|
55
|
-
queryKey: ["m2m-items", s.many_collection,
|
|
56
|
-
queryFn: () =>
|
|
55
|
+
queryKey: ["m2m-items", s.many_collection, R, o],
|
|
56
|
+
queryFn: () => y.request(
|
|
57
57
|
C(`/items/${s.many_collection}`, {
|
|
58
|
-
filter: JSON.stringify({ [
|
|
58
|
+
filter: JSON.stringify({ [R]: { _eq: o } }),
|
|
59
59
|
limit: 200,
|
|
60
60
|
fields: `id,${x}`
|
|
61
61
|
})
|
|
62
62
|
).then((e) => e.data ?? []),
|
|
63
63
|
staleTime: 3e4,
|
|
64
64
|
enabled: !!o && o !== "new"
|
|
65
|
-
}), re = pe().isAdmin,
|
|
65
|
+
}), re = pe().isAdmin, z = r === "nivaro_users" ? be(re) : null, E = he(r === "nivaro_users"), H = h ? z ? { _and: [h, z] } : h : z, j = H ? JSON.stringify(H) : void 0, v = b && !/^-?label$/.test(b) ? b : void 0, S = (() => {
|
|
66
66
|
const e = a == null ? void 0 : a.display_template;
|
|
67
67
|
if (!e || !e.includes(".")) return null;
|
|
68
68
|
const i = [...e.matchAll(/\{\{([^}]+)\}\}/g)].map((u) => u[1].trim());
|
|
@@ -73,10 +73,10 @@ function tt({
|
|
|
73
73
|
r,
|
|
74
74
|
L,
|
|
75
75
|
j,
|
|
76
|
-
|
|
76
|
+
v ?? "",
|
|
77
77
|
S ?? ""
|
|
78
78
|
],
|
|
79
|
-
queryFn: () =>
|
|
79
|
+
queryFn: () => y.request(
|
|
80
80
|
C(`/items/${r}`, {
|
|
81
81
|
limit: 200,
|
|
82
82
|
search: L || void 0,
|
|
@@ -85,14 +85,14 @@ function tt({
|
|
|
85
85
|
// A dotted display template ({{core_category.name}}) needs the
|
|
86
86
|
// nested expansion — a bare row only carries the FK id.
|
|
87
87
|
...S ? { fields: S } : {},
|
|
88
|
-
...
|
|
88
|
+
...v ? { sort: v } : {}
|
|
89
89
|
})
|
|
90
90
|
).then((e) => e.data ?? []),
|
|
91
91
|
enabled: P && !!r,
|
|
92
92
|
staleTime: j ? 0 : 3e4
|
|
93
|
-
}), B = (t == null ? void 0 : t.getStagedLinks(d)) ?? [],
|
|
93
|
+
}), B = (t == null ? void 0 : t.getStagedLinks(d)) ?? [], g = (t == null ? void 0 : t.getStagedUnlinks(d)) ?? /* @__PURE__ */ new Set(), U = X.filter((e) => !g.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({
|
|
94
94
|
queryKey: ["m2m-avail", r, _.join(","), j],
|
|
95
|
-
queryFn: () =>
|
|
95
|
+
queryFn: () => y.request(
|
|
96
96
|
C(`/items/${r}`, {
|
|
97
97
|
filter: Y,
|
|
98
98
|
picker: "1",
|
|
@@ -115,7 +115,7 @@ function tt({
|
|
|
115
115
|
}
|
|
116
116
|
const u = X.find((M) => String(M[x]) === i);
|
|
117
117
|
if (u) {
|
|
118
|
-
|
|
118
|
+
g.has(u.id) ? t == null || t.unstageUnlink(d, u.id) : t == null || t.stageUnlink(d, u.id);
|
|
119
119
|
return;
|
|
120
120
|
}
|
|
121
121
|
t == null || t.stageLink(d, e);
|
|
@@ -210,6 +210,7 @@ function tt({
|
|
|
210
210
|
"button",
|
|
211
211
|
{
|
|
212
212
|
type: "button",
|
|
213
|
+
"aria-label": "Remove",
|
|
213
214
|
onClick: () => t == null ? void 0 : t.stageUnlink(d, e.id),
|
|
214
215
|
className: "rounded-full p-0.5 text-slate-400 hover:text-red-500",
|
|
215
216
|
children: /* @__PURE__ */ n(oe, { className: "h-3 w-3" })
|
|
@@ -237,6 +238,7 @@ function tt({
|
|
|
237
238
|
"button",
|
|
238
239
|
{
|
|
239
240
|
type: "button",
|
|
241
|
+
"aria-label": "Remove",
|
|
240
242
|
onClick: () => t == null ? void 0 : t.unstageLink(d, e),
|
|
241
243
|
className: "rounded-full p-0.5 text-slate-400 hover:text-red-500",
|
|
242
244
|
children: /* @__PURE__ */ n(oe, { className: "h-3 w-3" })
|
|
@@ -255,7 +257,7 @@ function tt({
|
|
|
255
257
|
) }),
|
|
256
258
|
/* @__PURE__ */ n(Ce, { className: "w-[320px] p-0", align: "start", children: /* @__PURE__ */ c(xe, { shouldFilter: !1, children: [
|
|
257
259
|
/* @__PURE__ */ n(
|
|
258
|
-
|
|
260
|
+
ve,
|
|
259
261
|
{
|
|
260
262
|
placeholder: "Search…",
|
|
261
263
|
value: L,
|
|
@@ -263,10 +265,10 @@ function tt({
|
|
|
263
265
|
className: "h-9 text-[13px]"
|
|
264
266
|
}
|
|
265
267
|
),
|
|
266
|
-
/* @__PURE__ */ c(
|
|
268
|
+
/* @__PURE__ */ c(ge, { children: [
|
|
267
269
|
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 && (
|
|
269
|
-
(e, i) =>
|
|
270
|
+
/* @__PURE__ */ n(we, { children: !V && (v ? [...O] : [...O].sort(
|
|
271
|
+
(e, i) => b === "-label" ? k(i).localeCompare(k(e)) : k(e).localeCompare(k(i))
|
|
270
272
|
)).map((e) => {
|
|
271
273
|
const i = String(e.id), u = A.has(i);
|
|
272
274
|
return /* @__PURE__ */ c(
|
|
@@ -287,14 +289,14 @@ function tt({
|
|
|
287
289
|
}
|
|
288
290
|
),
|
|
289
291
|
r === "nivaro_users" && /* @__PURE__ */ n(
|
|
290
|
-
|
|
292
|
+
ye,
|
|
291
293
|
{
|
|
292
294
|
userId: i,
|
|
293
295
|
className: "h-4 w-4",
|
|
294
296
|
fallback: /* @__PURE__ */ n("span", { className: "flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-nvr-cyan/20 text-[8px] font-bold text-nvr-navy dark:text-nvr-cyan", children: je(k(e)) })
|
|
295
297
|
}
|
|
296
298
|
),
|
|
297
|
-
r === "nivaro_users" &&
|
|
299
|
+
r === "nivaro_users" && E.has(i.toUpperCase()) && /* @__PURE__ */ n(
|
|
298
300
|
"span",
|
|
299
301
|
{
|
|
300
302
|
className: "h-1.5 w-1.5 shrink-0 rounded-full bg-emerald-500",
|
|
@@ -318,31 +320,31 @@ function nt({
|
|
|
318
320
|
parentId: o,
|
|
319
321
|
allRelations: N,
|
|
320
322
|
extraFilter: h,
|
|
321
|
-
optionSort:
|
|
323
|
+
optionSort: b,
|
|
322
324
|
requiredParent: K,
|
|
323
325
|
onCountChange: J,
|
|
324
326
|
readOnly: D
|
|
325
327
|
}) {
|
|
326
|
-
const
|
|
328
|
+
const y = fe(), W = Ae(), t = Le(), [P, q] = ne(!1), [L, T] = ne(""), le = N.find(
|
|
327
329
|
(l) => l.many_collection === s.many_collection && l.many_field === s.junction_field && l.id !== s.id
|
|
328
|
-
), r = Te(le), x = s.junction_field ?? "",
|
|
330
|
+
), r = Te(le), x = s.junction_field ?? "", R = s.many_field ?? "", d = s.one_field ?? `${s.many_collection}.${x}`, { data: a } = w({
|
|
329
331
|
queryKey: ["col-meta", r],
|
|
330
|
-
queryFn: () =>
|
|
332
|
+
queryFn: () => y.request(C(`/collections/${r}`)).then((l) => l.data),
|
|
331
333
|
enabled: !!r,
|
|
332
334
|
staleTime: 3e5,
|
|
333
335
|
retry: !1
|
|
334
336
|
}), { data: X = [], isFetching: re } = w({
|
|
335
|
-
queryKey: ["m2m-items", s.many_collection,
|
|
336
|
-
queryFn: () =>
|
|
337
|
+
queryKey: ["m2m-items", s.many_collection, R, o],
|
|
338
|
+
queryFn: () => y.request(
|
|
337
339
|
C(`/items/${s.many_collection}`, {
|
|
338
|
-
filter: JSON.stringify({ [
|
|
340
|
+
filter: JSON.stringify({ [R]: { _eq: o } }),
|
|
339
341
|
limit: 1,
|
|
340
342
|
fields: `id,${x}`
|
|
341
343
|
})
|
|
342
344
|
).then((l) => l.data ?? []),
|
|
343
345
|
staleTime: 3e4,
|
|
344
346
|
enabled: !!o && o !== "new"
|
|
345
|
-
}),
|
|
347
|
+
}), z = pe().isAdmin, E = r === "nivaro_users" ? be(z) : null, H = he(r === "nivaro_users"), j = h ? E ? { _and: [h, E] } : h : E, v = j ? JSON.stringify(j) : void 0, S = b && !/^-?label$/.test(b) ? b : void 0, O = (() => {
|
|
346
348
|
const l = a == null ? void 0 : a.display_template;
|
|
347
349
|
if (!l || !l.includes(".")) return null;
|
|
348
350
|
const f = [...l.matchAll(/\{\{([^}]+)\}\}/g)].map((ee) => ee[1].trim());
|
|
@@ -352,15 +354,15 @@ function nt({
|
|
|
352
354
|
"m2m-options",
|
|
353
355
|
r,
|
|
354
356
|
L,
|
|
355
|
-
|
|
357
|
+
v,
|
|
356
358
|
S ?? "",
|
|
357
359
|
O ?? ""
|
|
358
360
|
],
|
|
359
|
-
queryFn: () =>
|
|
361
|
+
queryFn: () => y.request(
|
|
360
362
|
C(`/items/${r}`, {
|
|
361
363
|
limit: 200,
|
|
362
364
|
search: L || void 0,
|
|
363
|
-
filter:
|
|
365
|
+
filter: v,
|
|
364
366
|
picker: "1",
|
|
365
367
|
// A dotted display template ({{core_category.name}}) needs the
|
|
366
368
|
// nested expansion — a bare row only carries the FK id.
|
|
@@ -369,8 +371,8 @@ function nt({
|
|
|
369
371
|
})
|
|
370
372
|
).then((l) => l.data ?? []),
|
|
371
373
|
enabled: P && !!r,
|
|
372
|
-
staleTime:
|
|
373
|
-
}),
|
|
374
|
+
staleTime: v ? 0 : 3e4
|
|
375
|
+
}), g = (t == null ? void 0 : t.getStagedLinks(d)) ?? [], U = (t == null ? void 0 : t.getStagedUnlinks(d)) ?? /* @__PURE__ */ new Set(), p = X.find((l) => !U.has(l.id)) ?? null, _ = p ? p[x] : null, Y = g.length > 0 ? g[g.length - 1] : null, m = Y ?? _, Z = g.length > 0 || U.size > 0, $ = me(J);
|
|
374
376
|
$.current = J, ue(() => {
|
|
375
377
|
var l;
|
|
376
378
|
(l = $.current) == null || l.call($, m != null ? 1 : 0);
|
|
@@ -381,8 +383,8 @@ function nt({
|
|
|
381
383
|
enabled: !!r && m != null,
|
|
382
384
|
staleTime: 6e4
|
|
383
385
|
}), A = JSON.stringify(h ? { _and: [{ id: { _eq: m } }, h] } : { id: { _eq: m } }), { data: F } = w({
|
|
384
|
-
queryKey: ["relation-avail", r, String(m),
|
|
385
|
-
queryFn: () =>
|
|
386
|
+
queryKey: ["relation-avail", r, String(m), v],
|
|
387
|
+
queryFn: () => y.request(
|
|
386
388
|
C(`/items/${r}`, {
|
|
387
389
|
filter: A,
|
|
388
390
|
picker: "1",
|
|
@@ -400,11 +402,11 @@ function nt({
|
|
|
400
402
|
if (D)
|
|
401
403
|
return /* @__PURE__ */ n("span", { className: "block truncate text-[12px] text-slate-700 dark:text-slate-200", children: M ? "…" : se ?? "—" });
|
|
402
404
|
function Oe(l) {
|
|
403
|
-
for (const f of
|
|
405
|
+
for (const f of g) t == null || t.unstageLink(d, f);
|
|
404
406
|
p && !U.has(p.id) && (t == null || t.stageUnlink(d, p.id)), String(l) === String(_) && p ? t == null || t.unstageUnlink(d, p.id) : String(l) !== String(m) && (t == null || t.stageLink(d, l)), q(!1), T("");
|
|
405
407
|
}
|
|
406
408
|
function Ue() {
|
|
407
|
-
for (const l of
|
|
409
|
+
for (const l of g) t == null || t.unstageLink(d, l);
|
|
408
410
|
p && (t == null || t.stageUnlink(d, p.id)), q(!1);
|
|
409
411
|
}
|
|
410
412
|
return K ? /* @__PURE__ */ c(
|
|
@@ -459,7 +461,7 @@ function nt({
|
|
|
459
461
|
) }),
|
|
460
462
|
/* @__PURE__ */ n(Ce, { className: "w-[320px] p-0", align: "start", children: /* @__PURE__ */ c(xe, { shouldFilter: !1, children: [
|
|
461
463
|
/* @__PURE__ */ n(
|
|
462
|
-
|
|
464
|
+
ve,
|
|
463
465
|
{
|
|
464
466
|
placeholder: "Search…",
|
|
465
467
|
value: L,
|
|
@@ -481,10 +483,10 @@ function nt({
|
|
|
481
483
|
]
|
|
482
484
|
}
|
|
483
485
|
),
|
|
484
|
-
/* @__PURE__ */ c(
|
|
486
|
+
/* @__PURE__ */ c(ge, { children: [
|
|
485
487
|
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
488
|
!B && /* @__PURE__ */ n(we, { children: [...V].sort(
|
|
487
|
-
(l, f) => S ? 0 :
|
|
489
|
+
(l, f) => S ? 0 : b === "-label" ? i(f).localeCompare(i(l)) : i(l).localeCompare(i(f))
|
|
488
490
|
).map((l) => {
|
|
489
491
|
const f = String(l.id), ee = String(m) === f;
|
|
490
492
|
return /* @__PURE__ */ c(
|
|
@@ -505,7 +507,7 @@ function nt({
|
|
|
505
507
|
}
|
|
506
508
|
),
|
|
507
509
|
r === "nivaro_users" && /* @__PURE__ */ n(
|
|
508
|
-
|
|
510
|
+
ye,
|
|
509
511
|
{
|
|
510
512
|
userId: f,
|
|
511
513
|
className: "h-4 w-4",
|
|
@@ -3,12 +3,13 @@ import { useQueryClient as oe, useQuery as F } from "@tanstack/react-query";
|
|
|
3
3
|
import { Search as ie, X as de, Check as U, ChevronsUpDown as ce } from "lucide-react";
|
|
4
4
|
import { useState as L, useMemo as C } from "react";
|
|
5
5
|
import { useNivaroClient as Y } from "../../context.js";
|
|
6
|
-
import { get as Q, patch as
|
|
6
|
+
import { get as Q, patch as M, del as A, post as X } from "../../lib/commands.js";
|
|
7
|
+
import { userErrorMessage as ue } from "../../lib/safe-error.js";
|
|
7
8
|
import { matchesAllTokens as Z, titleCase as G, cn as K } from "../../lib/utils.js";
|
|
8
|
-
import { Popover as
|
|
9
|
-
import { applyDisplayTemplate as
|
|
10
|
-
import { RelationCombobox as
|
|
11
|
-
const
|
|
9
|
+
import { Popover as me, PopoverTrigger as pe, PopoverContent as be } from "../ui/popover.js";
|
|
10
|
+
import { applyDisplayTemplate as he } from "./helpers.js";
|
|
11
|
+
import { RelationCombobox as fe } from "./RelationCombobox.js";
|
|
12
|
+
const xe = 10;
|
|
12
13
|
async function P(t, l, p) {
|
|
13
14
|
const b = [];
|
|
14
15
|
for (let c = 1; c <= 50; c++) {
|
|
@@ -17,7 +18,7 @@ async function P(t, l, p) {
|
|
|
17
18
|
}
|
|
18
19
|
return b;
|
|
19
20
|
}
|
|
20
|
-
const
|
|
21
|
+
const ye = (t) => [...(t ?? "").matchAll(/\{\{([\w.]+)\}\}/g)].map((l) => l[1]);
|
|
21
22
|
function W(t, l) {
|
|
22
23
|
const p = Y(), { data: b } = F({
|
|
23
24
|
queryKey: ["collection-display-meta", t],
|
|
@@ -30,7 +31,7 @@ function W(t, l) {
|
|
|
30
31
|
}), c = (b == null ? void 0 : b.display_template) ?? null, i = l === "all" ? "all" : [...l].sort().join(","), { data: y = [], isLoading: N } = F({
|
|
31
32
|
queryKey: ["membership-set-labels", t, c, i],
|
|
32
33
|
queryFn: async () => {
|
|
33
|
-
const n =
|
|
34
|
+
const n = ye(c), u = n.length ? { fields: ["id", ...n].join(",") } : {};
|
|
34
35
|
if (l === "all") return P(p, `/items/${t}`, u);
|
|
35
36
|
const h = [];
|
|
36
37
|
for (let g = 0; g < l.length; g += 150)
|
|
@@ -49,12 +50,12 @@ function W(t, l) {
|
|
|
49
50
|
const n = /* @__PURE__ */ new Map();
|
|
50
51
|
for (const u of y) {
|
|
51
52
|
const h = String(u.name ?? u.title ?? u.label ?? `#${u.id}`);
|
|
52
|
-
n.set(String(u.id), (c ?
|
|
53
|
+
n.set(String(u.id), (c ? he(c, u) : "").trim() || h);
|
|
53
54
|
}
|
|
54
55
|
return n;
|
|
55
56
|
}, [y, c]), isLoading: N };
|
|
56
57
|
}
|
|
57
|
-
function
|
|
58
|
+
function Te({
|
|
58
59
|
relatedCollection: t,
|
|
59
60
|
manyField: l,
|
|
60
61
|
parentId: p,
|
|
@@ -98,18 +99,18 @@ function Ke({
|
|
|
98
99
|
await r();
|
|
99
100
|
} catch (a) {
|
|
100
101
|
const d = a == null ? void 0 : a.response;
|
|
101
|
-
O((d == null ? void 0 : d.error) ?? (a
|
|
102
|
+
O((d == null ? void 0 : d.error) ?? ue(a, "Could not save"));
|
|
102
103
|
} finally {
|
|
103
104
|
o(null), re();
|
|
104
105
|
}
|
|
105
106
|
}, ae = (e, r) => j(e, async () => {
|
|
106
107
|
const a = k.get(e) ?? [], d = a.find((w) => w.value === r), S = a.find((w) => w.value === null);
|
|
107
108
|
if (d) {
|
|
108
|
-
a.filter((v) => v.value !== null && v.id !== d.id).length === 0 && !S ? await i.request(
|
|
109
|
+
a.filter((v) => v.value !== null && v.id !== d.id).length === 0 && !S ? await i.request(M(`/items/${t}/${d.id}`, { [n]: null })) : await i.request(A(`/items/${t}/${d.id}`));
|
|
109
110
|
return;
|
|
110
111
|
}
|
|
111
112
|
S ? await i.request(
|
|
112
|
-
|
|
113
|
+
M(`/items/${t}/${S.id}`, { [n]: r })
|
|
113
114
|
) : await i.request(
|
|
114
115
|
X(`/items/${t}`, {
|
|
115
116
|
[l]: p,
|
|
@@ -122,11 +123,11 @@ function Ke({
|
|
|
122
123
|
if (a.length === 0) return;
|
|
123
124
|
const [d, ...S] = a, w = r.find((v) => v.value === null);
|
|
124
125
|
for (const v of w ? a : S)
|
|
125
|
-
await i.request(
|
|
126
|
-
w || await i.request(
|
|
126
|
+
await i.request(A(`/items/${t}/${v.id}`));
|
|
127
|
+
w || await i.request(M(`/items/${t}/${d.id}`, { [n]: null }));
|
|
127
128
|
}), le = (e) => j(e, async () => {
|
|
128
129
|
for (const r of k.get(e) ?? [])
|
|
129
|
-
await i.request(
|
|
130
|
+
await i.request(A(`/items/${t}/${r.id}`));
|
|
130
131
|
}), ne = (e) => {
|
|
131
132
|
e == null || e === "" || k.has(String(e)) || j(
|
|
132
133
|
String(e),
|
|
@@ -145,7 +146,7 @@ function Ke({
|
|
|
145
146
|
] }) : /* @__PURE__ */ m("div", { "data-membership-set": `${t}:${l}`, className: "space-y-2", children: [
|
|
146
147
|
!c && T && /* @__PURE__ */ m("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
147
148
|
/* @__PURE__ */ s("div", { className: "w-[320px] max-w-full", children: /* @__PURE__ */ s(
|
|
148
|
-
|
|
149
|
+
fe,
|
|
149
150
|
{
|
|
150
151
|
collection: T,
|
|
151
152
|
value: null,
|
|
@@ -195,7 +196,7 @@ function Ke({
|
|
|
195
196
|
children: [
|
|
196
197
|
/* @__PURE__ */ s("span", { className: "truncate font-medium text-slate-800 dark:text-foreground", "data-tip": e.label, children: e.label }),
|
|
197
198
|
/* @__PURE__ */ s(
|
|
198
|
-
|
|
199
|
+
ge,
|
|
199
200
|
{
|
|
200
201
|
options: te,
|
|
201
202
|
picked: a,
|
|
@@ -227,7 +228,7 @@ function Ke({
|
|
|
227
228
|
$ && /* @__PURE__ */ s("p", { className: "text-[12px] text-red-600 dark:text-red-400", children: $ })
|
|
228
229
|
] });
|
|
229
230
|
}
|
|
230
|
-
function
|
|
231
|
+
function ge({
|
|
231
232
|
options: t,
|
|
232
233
|
picked: l,
|
|
233
234
|
emptyLabel: p,
|
|
@@ -237,7 +238,7 @@ function ye({
|
|
|
237
238
|
onClear: y
|
|
238
239
|
}) {
|
|
239
240
|
const [N, f] = L(!1), [n, u] = L(""), h = l.size === 0;
|
|
240
|
-
if (t.length <=
|
|
241
|
+
if (t.length <= xe)
|
|
241
242
|
return /* @__PURE__ */ m("div", { className: "flex flex-wrap items-center gap-1", "data-membership-values": !0, children: [
|
|
242
243
|
/* @__PURE__ */ s(
|
|
243
244
|
"button",
|
|
@@ -277,8 +278,8 @@ function ye({
|
|
|
277
278
|
})
|
|
278
279
|
] });
|
|
279
280
|
const g = n.trim() ? t.filter((o) => Z(o.label, n)) : t, q = h ? p : t.filter((o) => l.has(o.id)).map((o) => o.label).join(", ");
|
|
280
|
-
return /* @__PURE__ */ m(
|
|
281
|
-
/* @__PURE__ */ s(
|
|
281
|
+
return /* @__PURE__ */ m(me, { open: N, onOpenChange: f, children: [
|
|
282
|
+
/* @__PURE__ */ s(pe, { asChild: !0, children: /* @__PURE__ */ m(
|
|
282
283
|
"button",
|
|
283
284
|
{
|
|
284
285
|
type: "button",
|
|
@@ -290,7 +291,7 @@ function ye({
|
|
|
290
291
|
]
|
|
291
292
|
}
|
|
292
293
|
) }),
|
|
293
|
-
/* @__PURE__ */ m(
|
|
294
|
+
/* @__PURE__ */ m(be, { align: "start", className: "w-[260px] p-1", children: [
|
|
294
295
|
/* @__PURE__ */ s(
|
|
295
296
|
"input",
|
|
296
297
|
{
|
|
@@ -316,5 +317,5 @@ function ye({
|
|
|
316
317
|
] });
|
|
317
318
|
}
|
|
318
319
|
export {
|
|
319
|
-
|
|
320
|
+
Te as MembershipSetField
|
|
320
321
|
};
|
|
@@ -4,10 +4,10 @@ import { Loader2 as Pe, Pencil as De, X as Ke } from "lucide-react";
|
|
|
4
4
|
import { useMemo as L, useRef as $e, useEffect as ke, useState as T, Fragment as je } from "react";
|
|
5
5
|
import { useNivaroClient as Le } from "../../context.js";
|
|
6
6
|
import { get as K, post as Te, patch as Fe, del as Ae } from "../../lib/commands.js";
|
|
7
|
-
import { titleCase as R, formatNumber as Je, cn as ue } from "../../lib/utils.js";
|
|
7
|
+
import { titleCase as R, formatNumber as Je, cn as ue, toLocalDateString as Ye } from "../../lib/utils.js";
|
|
8
8
|
import { FieldRenderer as fe } from "./FieldRenderer.js";
|
|
9
|
-
import { SENTINEL_FIELDS as
|
|
10
|
-
const
|
|
9
|
+
import { SENTINEL_FIELDS as Me, EMPTY_NESTED_OPS as O, applyDisplayTemplate as Se } from "./helpers.js";
|
|
10
|
+
const We = /* @__PURE__ */ new Set([
|
|
11
11
|
"alias",
|
|
12
12
|
"o2m",
|
|
13
13
|
"m2m",
|
|
@@ -15,8 +15,8 @@ const Se = /* @__PURE__ */ new Set([
|
|
|
15
15
|
"presentation",
|
|
16
16
|
"group",
|
|
17
17
|
"divider"
|
|
18
|
-
]),
|
|
19
|
-
function
|
|
18
|
+
]), ze = /* @__PURE__ */ new Set(["__apply_values__", "__create_with_defaults__"]);
|
|
19
|
+
function Ie(d, a) {
|
|
20
20
|
return d === a || d == null && a == null ? !0 : d == null || a == null ? !1 : typeof d == "string" && typeof a == "number" || typeof d == "number" && typeof a == "string" ? String(d) === String(a) : JSON.stringify(d) === JSON.stringify(a);
|
|
21
21
|
}
|
|
22
22
|
function me(d) {
|
|
@@ -28,7 +28,7 @@ function me(d) {
|
|
|
28
28
|
}
|
|
29
29
|
return a != null && a.message ? a.message : a != null && a.error ? a.error : d instanceof Error && d.message ? d.message : "Save failed";
|
|
30
30
|
}
|
|
31
|
-
function
|
|
31
|
+
function Oe({
|
|
32
32
|
parentCollection: d,
|
|
33
33
|
relationField: a,
|
|
34
34
|
parentRowId: x,
|
|
@@ -73,7 +73,7 @@ function Re({
|
|
|
73
73
|
staleTime: 6e4
|
|
74
74
|
}), E = L(
|
|
75
75
|
() => te.filter(
|
|
76
|
-
(e) => !e.hidden && !
|
|
76
|
+
(e) => !e.hidden && !We.has(e.type) && e.field !== v && !(Y && e.field in Y) && e.field !== "id" && !Me.has(e.field) && !ze.has(e.group_key ?? "")
|
|
77
77
|
),
|
|
78
78
|
[te, v]
|
|
79
79
|
), re = m ? ["nested-rows", c, JSON.stringify(J ?? null)] : ["nested-rows", c, v, x], { data: W = [], isLoading: Q } = j({
|
|
@@ -137,7 +137,7 @@ function Re({
|
|
|
137
137
|
$[u] = l, f == null || f({ ...s, created: $ });
|
|
138
138
|
} else {
|
|
139
139
|
const u = W.find((k) => String(k.id) === o), $ = Object.fromEntries(
|
|
140
|
-
Object.entries(r).filter(([k, Ee]) => !
|
|
140
|
+
Object.entries(r).filter(([k, Ee]) => !Ie(Ee, u == null ? void 0 : u[k]))
|
|
141
141
|
), de = s.updated.filter((k) => k.id !== o);
|
|
142
142
|
Object.keys($).length > 0 && de.push({ id: o, changes: $ }), f == null || f({ ...s, updated: de });
|
|
143
143
|
}
|
|
@@ -237,7 +237,7 @@ function Re({
|
|
|
237
237
|
]);
|
|
238
238
|
e[t] = {};
|
|
239
239
|
for (const u of s.data ?? [])
|
|
240
|
-
e[t][String(u.id)] =
|
|
240
|
+
e[t][String(u.id)] = Se(
|
|
241
241
|
(l = i.data) == null ? void 0 : l.display_template,
|
|
242
242
|
u
|
|
243
243
|
);
|
|
@@ -260,7 +260,7 @@ function Re({
|
|
|
260
260
|
return /* @__PURE__ */ n("span", { className: t ? "text-emerald-600" : "text-slate-400", children: t ? "Yes" : "No" });
|
|
261
261
|
if (e.type === "datetime" || e.type === "date")
|
|
262
262
|
try {
|
|
263
|
-
return /* @__PURE__ */ n("span", { className: "block truncate", children:
|
|
263
|
+
return /* @__PURE__ */ n("span", { className: "block truncate", children: Ye(t) });
|
|
264
264
|
} catch {
|
|
265
265
|
}
|
|
266
266
|
return /* @__PURE__ */ n("span", { className: "block truncate", children: String(t) });
|
|
@@ -470,5 +470,5 @@ function Re({
|
|
|
470
470
|
] });
|
|
471
471
|
}
|
|
472
472
|
export {
|
|
473
|
-
|
|
473
|
+
Oe as NestedRelationEditor
|
|
474
474
|
};
|
|
@@ -4,8 +4,9 @@ import { Plus as _, Loader2 as E } from "lucide-react";
|
|
|
4
4
|
import { useState as m } from "react";
|
|
5
5
|
import { useNivaroClient as F, useParentDraft as K } from "../../context.js";
|
|
6
6
|
import { get as P, post as z } from "../../lib/commands.js";
|
|
7
|
-
import {
|
|
8
|
-
|
|
7
|
+
import { userErrorMessage as A } from "../../lib/safe-error.js";
|
|
8
|
+
import { cn as B, titleCase as p } from "../../lib/utils.js";
|
|
9
|
+
function H({
|
|
9
10
|
targetCollection: r,
|
|
10
11
|
config: i,
|
|
11
12
|
onCreated: c
|
|
@@ -40,7 +41,7 @@ function G({
|
|
|
40
41
|
for (const t of q) {
|
|
41
42
|
const n = C(t.from);
|
|
42
43
|
if (f != null && f.has(t.field)) {
|
|
43
|
-
const $ =
|
|
44
|
+
const $ = I(n);
|
|
44
45
|
$.length > 0 && (e[t.field] = $);
|
|
45
46
|
continue;
|
|
46
47
|
}
|
|
@@ -57,7 +58,7 @@ function G({
|
|
|
57
58
|
if (n == null) throw new Error("Created record returned no id");
|
|
58
59
|
d.invalidateQueries({ queryKey: ["relation-opts", r] }), c(n), b(!1), N({});
|
|
59
60
|
} catch (t) {
|
|
60
|
-
u(t
|
|
61
|
+
u(A(t, "Create failed"));
|
|
61
62
|
} finally {
|
|
62
63
|
k(!1);
|
|
63
64
|
}
|
|
@@ -69,7 +70,7 @@ function G({
|
|
|
69
70
|
type: "button",
|
|
70
71
|
title: i.title ?? `New ${p(r)}`,
|
|
71
72
|
onClick: () => b((e) => !e),
|
|
72
|
-
className:
|
|
73
|
+
className: B(
|
|
73
74
|
"inline-flex h-9 items-center gap-1 rounded-md border px-2.5 text-[12px] transition-colors",
|
|
74
75
|
h ? "border-nvr-cyan bg-nvr-cyan/10 text-nvr-cyan" : "border-input text-slate-600 hover:border-slate-400 hover:text-slate-800 dark:text-slate-300"
|
|
75
76
|
),
|
|
@@ -125,7 +126,7 @@ function G({
|
|
|
125
126
|
] })
|
|
126
127
|
] });
|
|
127
128
|
}
|
|
128
|
-
function
|
|
129
|
+
function I(r) {
|
|
129
130
|
const i = Array.isArray(r) ? r : [r], c = [];
|
|
130
131
|
for (const a of i) {
|
|
131
132
|
const d = a != null && typeof a == "object" ? a.id : a;
|
|
@@ -134,5 +135,5 @@ function B(r) {
|
|
|
134
135
|
return c;
|
|
135
136
|
}
|
|
136
137
|
export {
|
|
137
|
-
|
|
138
|
+
H as QuickCreateButton
|
|
138
139
|
};
|