@nivaro/react 0.3.64 → 0.3.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +49 -4
- package/dist/shared/components/CollectionBrowserView.js +3029 -2947
- package/dist/shared/components/ConformanceView.js +235 -221
- package/dist/shared/components/DataTable.js +478 -459
- package/dist/shared/components/ItemEditForm.js +4469 -4266
- package/dist/shared/components/PageRenderer.js +146 -138
- package/dist/shared/components/RecordDrilldownSheet.js +73 -65
- package/dist/shared/components/bulk/BulkActionButtons.js +72 -72
- package/dist/shared/components/bulk/BulkFieldUpdate.js +114 -103
- package/dist/shared/components/bulk/BulkFieldUpdateButton.js +73 -0
- package/dist/shared/components/bulk/bulk-field-options.js +29 -23
- package/dist/shared/components/integrations/IntegrationObligationsView.js +191 -173
- package/dist/shared/components/integrations/IntegrationStatusLines.js +101 -85
- package/dist/shared/components/integrations/RecordIntegrationPreview.js +11 -9
- package/dist/shared/components/integrations/SendCurrentData.js +126 -0
- package/dist/shared/components/item-edit/CatalogPickerField.js +1530 -1437
- package/dist/shared/components/item-edit/FieldRenderer.js +49 -45
- package/dist/shared/components/item-edit/FieldRow.js +413 -403
- package/dist/shared/components/item-edit/InlineTableField.js +2903 -2816
- package/dist/shared/components/item-edit/M2MCombobox.js +172 -168
- package/dist/shared/components/item-edit/MidairCollisionDialog.js +341 -114
- package/dist/shared/components/item-edit/NestedRelationEditor.js +171 -163
- package/dist/shared/components/item-edit/PlanGrid.js +783 -724
- package/dist/shared/components/item-edit/QuickCreateButton.js +291 -224
- package/dist/shared/components/item-edit/RecordInsights.js +113 -111
- package/dist/shared/components/item-edit/RecordLiveSync.js +4 -1
- package/dist/shared/components/item-edit/RelationCombobox.js +332 -314
- package/dist/shared/components/item-edit/cascade-clear-notice.js +52 -0
- package/dist/shared/components/item-edit/collision-format.js +37 -0
- package/dist/shared/components/item-edit/field-a11y.js +25 -0
- package/dist/shared/components/item-edit/line-merge.js +58 -0
- package/dist/shared/components/item-edit/line-midair.js +94 -87
- package/dist/shared/components/item-edit/move-guard.js +17 -0
- package/dist/shared/components/item-edit/picker-search.js +22 -15
- package/dist/shared/components/item-edit/rail-width.js +8 -0
- package/dist/shared/components/monitoring/InactiveUserLinksView.js +126 -124
- package/dist/shared/components/panels/AccessDeniedPanel.js +96 -55
- package/dist/shared/components/panels/CommentPanel.js +142 -136
- package/dist/shared/components/panels/ItemLockBanner.js +246 -240
- package/dist/shared/components/panels/PipelinePanel.js +1366 -1194
- package/dist/shared/components/panels/RevisionsPanel.js +106 -102
- package/dist/shared/components/panels/SlaBreachBanner.js +16 -20
- package/dist/shared/components/panels/SlaClock.js +90 -68
- package/dist/shared/components/queue/QueueItemSheet.js +94 -87
- package/dist/shared/components/queue/QueueWorklist.js +1502 -1354
- package/dist/shared/components/queue/worklist-csv.js +75 -0
- package/dist/shared/components/queue/worklist-helpers.js +20 -0
- package/dist/shared/components/widgets/ReviewListWidget.js +226 -207
- package/dist/shared/lib/bulk-copy.js +17 -0
- package/dist/shared/lib/cbv-export.js +122 -0
- package/dist/shared/lib/delete-offer.js +13 -0
- package/dist/shared/lib/error-hints.js +1 -0
- package/dist/shared/lib/leave-guard.js +41 -26
- package/dist/shared/lib/list-link.js +72 -56
- package/dist/shared/lib/live-queries.js +32 -30
- package/dist/shared/lib/moved-notice.js +25 -0
- package/dist/shared/lib/notification-target.js +56 -54
- package/dist/shared/lib/obligation-banner.js +11 -8
- package/dist/shared/lib/obligation-reason-text.js +6 -6
- package/dist/shared/lib/sort-cycle.js +6 -0
- package/dist/shared/lib/summary-mode.js +59 -41
- package/package.json +1 -1
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { jsx as l, jsxs as
|
|
2
|
-
import { useQuery as
|
|
1
|
+
import { jsx as l, jsxs as d } from "react/jsx-runtime";
|
|
2
|
+
import { useQuery as q } from "@tanstack/react-query";
|
|
3
3
|
import { ChevronDown as re, Loader2 as ce, AlertTriangle as ue, X as de, Check as me } from "lucide-react";
|
|
4
4
|
import { useState as se, useRef as fe, useEffect as pe } from "react";
|
|
5
|
-
import { useNivaroClient as he, useItemEditAuth as be, useDrilldown as
|
|
6
|
-
import { parseAllowedCollections as
|
|
5
|
+
import { useNivaroClient as he, useItemEditAuth as be, useDrilldown as Je } from "../../context.js";
|
|
6
|
+
import { parseAllowedCollections as Pe } from "../../lib/allowed-collections.js";
|
|
7
7
|
import { get as U } from "../../lib/commands.js";
|
|
8
8
|
import { compareByMatch as ye } from "../../lib/picker-rank.js";
|
|
9
9
|
import { useRecordReader as Ee } from "../../lib/record-loader.js";
|
|
10
10
|
import { useOnlineUsers as xe } from "../../lib/use-online-users.js";
|
|
11
|
-
import { cn as
|
|
11
|
+
import { cn as Q, userOptionFilter as ge, matchesAllTokens as Re } from "../../lib/utils.js";
|
|
12
12
|
import { UserAvatar as ve } from "../UserAvatar.js";
|
|
13
|
-
import { Command as ke, CommandInput as
|
|
14
|
-
import { Popover as Ce, PopoverTrigger as
|
|
13
|
+
import { Command as ke, CommandInput as we, CommandList as Se, CommandEmpty as Ne, CommandGroup as _e, CommandItem as Le } from "../ui/command.js";
|
|
14
|
+
import { Popover as Ce, PopoverTrigger as Oe, PopoverContent as qe } from "../ui/popover.js";
|
|
15
15
|
import { applyDisplayTemplate as Fe } from "./helpers.js";
|
|
16
16
|
import { useM2MStaging as je } from "./M2MStagingContext.js";
|
|
17
17
|
import { useStaleTip as ze, RelatedItemLabel as oe } from "./RelationCombobox.js";
|
|
@@ -19,9 +19,9 @@ function Te(n) {
|
|
|
19
19
|
return n.replace(/\(.*$/, "").trim().split(/\s+/).map((i) => i[0]).filter(Boolean).slice(0, 2).join("").toUpperCase() || "?";
|
|
20
20
|
}
|
|
21
21
|
function Ie(n) {
|
|
22
|
-
return
|
|
22
|
+
return Pe(n == null ? void 0 : n.one_allowed_collections);
|
|
23
23
|
}
|
|
24
|
-
function
|
|
24
|
+
function Ae(n) {
|
|
25
25
|
if (!n) return null;
|
|
26
26
|
if (n.one_collection) return n.one_collection;
|
|
27
27
|
const i = Ie(n);
|
|
@@ -34,58 +34,58 @@ function ot(n) {
|
|
|
34
34
|
const p = i.includes("directus_users") ? "directus_users" : i.includes("nivaro_users") ? "nivaro_users" : i[0];
|
|
35
35
|
return { field: n.one_collection_field ?? "collection", value: p };
|
|
36
36
|
}
|
|
37
|
-
function
|
|
37
|
+
function W(n) {
|
|
38
38
|
return String(n).toLowerCase();
|
|
39
39
|
}
|
|
40
40
|
function ct({
|
|
41
41
|
relation: n,
|
|
42
42
|
parentId: i,
|
|
43
43
|
allRelations: p,
|
|
44
|
-
extraFilter:
|
|
44
|
+
extraFilter: u,
|
|
45
45
|
optionSort: h,
|
|
46
|
-
requiredParent:
|
|
47
|
-
onCountChange:
|
|
48
|
-
drilldown:
|
|
46
|
+
requiredParent: N,
|
|
47
|
+
onCountChange: _,
|
|
48
|
+
drilldown: F
|
|
49
49
|
}) {
|
|
50
|
-
const x = he(),
|
|
50
|
+
const x = he(), T = Je(), t = je(), [k, v] = se(!1), [y, L] = se(""), I = p.find(
|
|
51
51
|
(e) => e.many_collection === n.many_collection && e.many_field === n.junction_field && e.id !== n.id
|
|
52
|
-
), s =
|
|
52
|
+
), s = Ae(I), C = n.junction_field ?? "", P = n.many_field ?? "", m = n.one_field ?? `${n.many_collection}.${C}`, { data: o } = q({
|
|
53
53
|
queryKey: ["col-meta", s],
|
|
54
54
|
queryFn: () => x.request(U(`/collections/${s}`)).then((e) => e.data),
|
|
55
55
|
enabled: !!s,
|
|
56
56
|
staleTime: 3e5,
|
|
57
57
|
retry: !1
|
|
58
|
-
}), { data: X = [] } =
|
|
58
|
+
}), { data: X = [] } = q({
|
|
59
59
|
queryKey: ["m2m-items", n.many_collection, P, i],
|
|
60
60
|
queryFn: () => x.request(
|
|
61
61
|
U(`/items/${n.many_collection}`, {
|
|
62
62
|
filter: JSON.stringify({ [P]: { _eq: i } }),
|
|
63
63
|
limit: 200,
|
|
64
|
-
fields: `id,${
|
|
64
|
+
fields: `id,${C}`
|
|
65
65
|
})
|
|
66
66
|
).then((e) => e.data ?? []),
|
|
67
67
|
staleTime: 3e4,
|
|
68
68
|
enabled: !!i && i !== "new"
|
|
69
|
-
}), ae = be().isAdmin,
|
|
69
|
+
}), ae = be().isAdmin, E = s === "nivaro_users" ? ge(ae) : null, R = xe(s === "nivaro_users"), H = u ? E ? { _and: [u, E] } : u : E, z = H ? JSON.stringify(H) : void 0, M = h && !/^-?label$/.test(h) ? h : void 0, Y = (() => {
|
|
70
70
|
const e = o == null ? void 0 : o.display_template;
|
|
71
71
|
if (!e || !e.includes(".")) return null;
|
|
72
|
-
const a = [...e.matchAll(/\{\{([^}]+)\}\}/g)].map((
|
|
72
|
+
const a = [...e.matchAll(/\{\{([^}]+)\}\}/g)].map((c) => c[1].trim());
|
|
73
73
|
return a.length === 0 ? null : ["id", ...a].join(",");
|
|
74
74
|
})(), {
|
|
75
75
|
options: Z,
|
|
76
|
-
isLoading:
|
|
77
|
-
localSearch:
|
|
78
|
-
} =
|
|
76
|
+
isLoading: B,
|
|
77
|
+
localSearch: G
|
|
78
|
+
} = Ue({
|
|
79
79
|
client: x,
|
|
80
80
|
relatedCollection: s,
|
|
81
81
|
search: y,
|
|
82
|
-
filterParam:
|
|
83
|
-
serverSort:
|
|
82
|
+
filterParam: z,
|
|
83
|
+
serverSort: M,
|
|
84
84
|
templateNestedFields: Y,
|
|
85
|
-
enabled:
|
|
86
|
-
labelOf:
|
|
87
|
-
}), ee = (t == null ? void 0 : t.getStagedLinks(
|
|
88
|
-
queryKey: ["m2m-avail", s,
|
|
85
|
+
enabled: k && !!s,
|
|
86
|
+
labelOf: w
|
|
87
|
+
}), ee = (t == null ? void 0 : t.getStagedLinks(m)) ?? [], O = (t == null ? void 0 : t.getStagedUnlinks(m)) ?? /* @__PURE__ */ new Set(), K = X.filter((e) => !O.has(e.id)), g = new Set(K.map((e) => String(e[C]))), j = [...g], te = JSON.stringify(u ? { _and: [{ id: { _in: j } }, u] } : { id: { _in: j } }), { data: f } = q({
|
|
88
|
+
queryKey: ["m2m-avail", s, j.join(","), z],
|
|
89
89
|
queryFn: () => x.request(
|
|
90
90
|
U(`/items/${s}`, {
|
|
91
91
|
filter: te,
|
|
@@ -94,64 +94,68 @@ function ct({
|
|
|
94
94
|
fields: "id"
|
|
95
95
|
})
|
|
96
96
|
).then((e) => e.data ?? []),
|
|
97
|
-
enabled: !!s &&
|
|
97
|
+
enabled: !!s && j.length > 0,
|
|
98
98
|
staleTime: 3e4
|
|
99
|
-
}), ne = new Set((
|
|
100
|
-
|
|
99
|
+
}), ne = new Set((f ?? []).map((e) => String(e.id))), $ = f !== void 0 ? new Set(j.filter((e) => !ne.has(e))) : /* @__PURE__ */ new Set(), D = new Set(ee.map(W)), J = /* @__PURE__ */ new Set([...[...g].map(W), ...D]), A = fe(_);
|
|
100
|
+
A.current = _, pe(() => {
|
|
101
101
|
var e;
|
|
102
|
-
(e =
|
|
102
|
+
(e = A.current) == null || e.call(A, J.size);
|
|
103
103
|
}, [J.size]);
|
|
104
|
-
function
|
|
105
|
-
const a =
|
|
106
|
-
if (
|
|
107
|
-
t == null || t.unstageLink(
|
|
104
|
+
function V(e) {
|
|
105
|
+
const a = W(e);
|
|
106
|
+
if (D.has(a)) {
|
|
107
|
+
t == null || t.unstageLink(m, e);
|
|
108
108
|
return;
|
|
109
109
|
}
|
|
110
|
-
const
|
|
111
|
-
if (
|
|
112
|
-
|
|
110
|
+
const c = X.find((S) => W(S[C]) === a);
|
|
111
|
+
if (c) {
|
|
112
|
+
O.has(c.id) ? t == null || t.unstageUnlink(m, c.id) : t == null || t.stageUnlink(m, c.id);
|
|
113
113
|
return;
|
|
114
114
|
}
|
|
115
|
-
t == null || t.stageLink(
|
|
115
|
+
t == null || t.stageLink(m, e);
|
|
116
116
|
}
|
|
117
|
-
function
|
|
117
|
+
function w(e) {
|
|
118
118
|
const a = (o == null ? void 0 : o.display_template) ?? null;
|
|
119
119
|
return a ? Fe(a, e) : String(e._display ?? e.id ?? "");
|
|
120
120
|
}
|
|
121
|
-
return
|
|
121
|
+
return N ? /* @__PURE__ */ d(
|
|
122
122
|
"button",
|
|
123
123
|
{
|
|
124
124
|
type: "button",
|
|
125
125
|
disabled: !0,
|
|
126
126
|
className: "flex h-9 w-full items-center justify-between gap-2 rounded-md border border-input bg-background px-3 text-sm text-muted-foreground opacity-50 cursor-not-allowed",
|
|
127
127
|
children: [
|
|
128
|
-
/* @__PURE__ */
|
|
128
|
+
/* @__PURE__ */ d("span", { className: "truncate", children: [
|
|
129
129
|
"Select ",
|
|
130
|
-
|
|
130
|
+
N,
|
|
131
131
|
" first"
|
|
132
132
|
] }),
|
|
133
133
|
/* @__PURE__ */ l(re, { className: "h-4 w-4 shrink-0 opacity-50" })
|
|
134
134
|
]
|
|
135
135
|
}
|
|
136
|
-
) : /* @__PURE__ */ l("div", { children: /* @__PURE__ */
|
|
136
|
+
) : /* @__PURE__ */ l("div", { children: /* @__PURE__ */ d(
|
|
137
137
|
Ce,
|
|
138
138
|
{
|
|
139
|
-
open:
|
|
139
|
+
open: k,
|
|
140
140
|
onOpenChange: (e) => {
|
|
141
|
-
v(e), e ||
|
|
141
|
+
v(e), e || L("");
|
|
142
142
|
},
|
|
143
143
|
children: [
|
|
144
|
-
/* @__PURE__ */ l(
|
|
144
|
+
/* @__PURE__ */ l(Oe, { asChild: !0, children: /* @__PURE__ */ d(
|
|
145
145
|
"div",
|
|
146
146
|
{
|
|
147
147
|
role: "button",
|
|
148
148
|
tabIndex: 0,
|
|
149
149
|
onKeyDown: (e) => {
|
|
150
|
-
(e.key ===
|
|
150
|
+
if (e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey && (k || y !== "" || e.key !== " ")) {
|
|
151
|
+
e.preventDefault();
|
|
152
|
+
const c = e.key;
|
|
153
|
+
L((S) => c === " " && (S === "" || S.endsWith(" ")) ? S : S + c), k || v(!0);
|
|
154
|
+
} else (e.key === "Enter" || e.key === " " || !k && e.key === "ArrowDown") && (e.preventDefault(), v((c) => !c));
|
|
151
155
|
},
|
|
152
156
|
className: "flex min-h-9 w-full cursor-pointer items-center justify-between gap-2 rounded-md border border-input bg-background px-3 py-1 text-sm text-left font-normal hover:bg-muted",
|
|
153
157
|
children: [
|
|
154
|
-
J.size > 0 ? /* @__PURE__ */
|
|
158
|
+
J.size > 0 ? /* @__PURE__ */ d(
|
|
155
159
|
"span",
|
|
156
160
|
{
|
|
157
161
|
className: "flex min-w-0 flex-1 flex-wrap items-center gap-1",
|
|
@@ -159,28 +163,28 @@ function ct({
|
|
|
159
163
|
e.target.closest("button") && e.stopPropagation();
|
|
160
164
|
},
|
|
161
165
|
children: [
|
|
162
|
-
|
|
163
|
-
const a = e[
|
|
164
|
-
return /* @__PURE__ */
|
|
166
|
+
K.map((e) => {
|
|
167
|
+
const a = e[C], c = $.has(String(a));
|
|
168
|
+
return /* @__PURE__ */ d(
|
|
165
169
|
"span",
|
|
166
170
|
{
|
|
167
|
-
title:
|
|
168
|
-
className:
|
|
171
|
+
title: c ? "This record is no longer an available option" : void 0,
|
|
172
|
+
className: Q(
|
|
169
173
|
"inline-flex items-center gap-1 rounded-full border pl-2.5 pr-1.5 py-0.5 text-[12px]",
|
|
170
|
-
|
|
174
|
+
c ? "border-amber-300 bg-amber-50 text-amber-700 dark:border-amber-600 dark:bg-amber-950/30 dark:text-amber-400" : "border-slate-200 bg-slate-50 text-slate-700 dark:border-border dark:bg-muted dark:text-slate-200"
|
|
171
175
|
),
|
|
172
176
|
children: [
|
|
173
|
-
|
|
174
|
-
s && (
|
|
177
|
+
c && /* @__PURE__ */ l(ue, { className: "h-3 w-3 shrink-0 text-amber-500" }),
|
|
178
|
+
s && (F && T ? /* @__PURE__ */ l(
|
|
175
179
|
"button",
|
|
176
180
|
{
|
|
177
181
|
type: "button",
|
|
178
182
|
title: "Open detail panel",
|
|
179
|
-
onClick: () =>
|
|
183
|
+
onClick: () => T.open({
|
|
180
184
|
collection: s,
|
|
181
185
|
itemId: String(a),
|
|
182
|
-
layoutId:
|
|
183
|
-
width:
|
|
186
|
+
layoutId: F.layout_id,
|
|
187
|
+
width: F.width
|
|
184
188
|
}),
|
|
185
189
|
className: "underline decoration-slate-300 decoration-dotted underline-offset-2 hover:text-[#172940] hover:decoration-nvr-cyan dark:hover:text-nvr-cyan",
|
|
186
190
|
children: /* @__PURE__ */ l(
|
|
@@ -205,7 +209,7 @@ function ct({
|
|
|
205
209
|
{
|
|
206
210
|
type: "button",
|
|
207
211
|
"aria-label": "Remove",
|
|
208
|
-
onClick: () => t == null ? void 0 : t.stageUnlink(
|
|
212
|
+
onClick: () => t == null ? void 0 : t.stageUnlink(m, e.id),
|
|
209
213
|
className: "rounded-full p-0.5 text-slate-400 hover:text-red-500",
|
|
210
214
|
children: /* @__PURE__ */ l(de, { className: "h-3 w-3" })
|
|
211
215
|
}
|
|
@@ -215,7 +219,7 @@ function ct({
|
|
|
215
219
|
String(e.id)
|
|
216
220
|
);
|
|
217
221
|
}),
|
|
218
|
-
ee.map((e) => /* @__PURE__ */
|
|
222
|
+
ee.map((e) => /* @__PURE__ */ d(
|
|
219
223
|
"span",
|
|
220
224
|
{
|
|
221
225
|
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",
|
|
@@ -233,7 +237,7 @@ function ct({
|
|
|
233
237
|
{
|
|
234
238
|
type: "button",
|
|
235
239
|
"aria-label": "Remove",
|
|
236
|
-
onClick: () => t == null ? void 0 : t.unstageLink(
|
|
240
|
+
onClick: () => t == null ? void 0 : t.unstageLink(m, e),
|
|
237
241
|
className: "rounded-full p-0.5 text-slate-400 hover:text-red-500",
|
|
238
242
|
children: /* @__PURE__ */ l(de, { className: "h-3 w-3" })
|
|
239
243
|
}
|
|
@@ -249,37 +253,37 @@ function ct({
|
|
|
249
253
|
]
|
|
250
254
|
}
|
|
251
255
|
) }),
|
|
252
|
-
/* @__PURE__ */ l(
|
|
256
|
+
/* @__PURE__ */ l(qe, { className: "w-[320px] p-0", align: "start", children: /* @__PURE__ */ d(ke, { shouldFilter: !1, children: [
|
|
253
257
|
/* @__PURE__ */ l(
|
|
254
|
-
|
|
258
|
+
we,
|
|
255
259
|
{
|
|
256
260
|
placeholder: "Search…",
|
|
257
261
|
value: y,
|
|
258
|
-
onValueChange:
|
|
262
|
+
onValueChange: L,
|
|
259
263
|
className: "h-9 text-[13px]"
|
|
260
264
|
}
|
|
261
265
|
),
|
|
262
|
-
/* @__PURE__ */
|
|
263
|
-
|
|
264
|
-
/* @__PURE__ */ l(_e, { children: !
|
|
265
|
-
(e, a) => ye(
|
|
266
|
+
/* @__PURE__ */ d(Se, { children: [
|
|
267
|
+
B ? /* @__PURE__ */ l("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ l(ce, { className: "h-4 w-4 animate-spin text-muted-foreground" }) }) : /* @__PURE__ */ l(Ne, { className: "py-3 text-left text-[12px] text-muted-foreground px-3", children: "No results" }),
|
|
268
|
+
/* @__PURE__ */ l(_e, { children: !B && (M ? [...ie(Z, y, G, w)] : [...ie(Z, y, G, w)].sort(
|
|
269
|
+
(e, a) => ye(w(e), w(a), y, h === "-label")
|
|
266
270
|
)).map((e) => {
|
|
267
|
-
const a = String(e.id),
|
|
268
|
-
return /* @__PURE__ */
|
|
271
|
+
const a = String(e.id), c = J.has(W(a));
|
|
272
|
+
return /* @__PURE__ */ d(
|
|
269
273
|
Le,
|
|
270
274
|
{
|
|
271
275
|
value: a,
|
|
272
|
-
onSelect: () =>
|
|
276
|
+
onSelect: () => V(e.id),
|
|
273
277
|
className: "flex items-center gap-2 text-[13px]",
|
|
274
278
|
children: [
|
|
275
279
|
/* @__PURE__ */ l(
|
|
276
280
|
"div",
|
|
277
281
|
{
|
|
278
|
-
className:
|
|
282
|
+
className: Q(
|
|
279
283
|
"flex h-4 w-4 shrink-0 items-center justify-center rounded border",
|
|
280
|
-
|
|
284
|
+
c ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300 dark:border-slate-500"
|
|
281
285
|
),
|
|
282
|
-
children:
|
|
286
|
+
children: c && /* @__PURE__ */ l(me, { className: "h-2.5 w-2.5 text-white" })
|
|
283
287
|
}
|
|
284
288
|
),
|
|
285
289
|
s === "nivaro_users" && /* @__PURE__ */ l(
|
|
@@ -287,17 +291,17 @@ function ct({
|
|
|
287
291
|
{
|
|
288
292
|
userId: a,
|
|
289
293
|
className: "h-4 w-4",
|
|
290
|
-
fallback: /* @__PURE__ */ l("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: Te(
|
|
294
|
+
fallback: /* @__PURE__ */ l("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: Te(w(e)) })
|
|
291
295
|
}
|
|
292
296
|
),
|
|
293
|
-
s === "nivaro_users" &&
|
|
297
|
+
s === "nivaro_users" && R.has(a.toUpperCase()) && /* @__PURE__ */ l(
|
|
294
298
|
"span",
|
|
295
299
|
{
|
|
296
300
|
className: "h-1.5 w-1.5 shrink-0 rounded-full bg-emerald-500",
|
|
297
301
|
"data-tip": "Online now"
|
|
298
302
|
}
|
|
299
303
|
),
|
|
300
|
-
/* @__PURE__ */ l("span", { className: "truncate", children:
|
|
304
|
+
/* @__PURE__ */ l("span", { className: "truncate", children: w(e) })
|
|
301
305
|
]
|
|
302
306
|
},
|
|
303
307
|
a
|
|
@@ -309,104 +313,104 @@ function ct({
|
|
|
309
313
|
}
|
|
310
314
|
) });
|
|
311
315
|
}
|
|
312
|
-
function
|
|
313
|
-
const { client: i, relatedCollection: p, search:
|
|
316
|
+
function Ue(n) {
|
|
317
|
+
const { client: i, relatedCollection: p, search: u, filterParam: h, serverSort: N, templateNestedFields: _ } = n, F = (I) => i.request(
|
|
314
318
|
U(`/items/${p}`, {
|
|
315
|
-
limit:
|
|
316
|
-
search:
|
|
319
|
+
limit: Ke,
|
|
320
|
+
search: I || void 0,
|
|
317
321
|
filter: h,
|
|
318
322
|
picker: "1",
|
|
319
323
|
// A dotted display template ({{core_category.name}}) needs the
|
|
320
324
|
// nested expansion — a bare row only carries the FK id.
|
|
321
|
-
...
|
|
322
|
-
...
|
|
325
|
+
..._ ? { fields: _ } : {},
|
|
326
|
+
...N ? { sort: N } : {}
|
|
323
327
|
})
|
|
324
|
-
).then((s) => s.data ?? []), x = (
|
|
328
|
+
).then((s) => s.data ?? []), x = (I) => [
|
|
325
329
|
"m2m-options",
|
|
326
330
|
p,
|
|
327
|
-
|
|
331
|
+
I,
|
|
328
332
|
h,
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
],
|
|
333
|
+
N ?? "",
|
|
334
|
+
_ ?? ""
|
|
335
|
+
], T = h ? 0 : 3e4, { data: t, isFetching: k } = q({
|
|
332
336
|
queryKey: x(""),
|
|
333
|
-
queryFn: () =>
|
|
337
|
+
queryFn: () => F(""),
|
|
334
338
|
enabled: n.enabled,
|
|
335
|
-
staleTime:
|
|
336
|
-
}), v = Me(t,
|
|
337
|
-
queryKey: x(
|
|
338
|
-
queryFn: () =>
|
|
339
|
+
staleTime: T
|
|
340
|
+
}), v = Me(t, u, n.labelOf), { data: y, isFetching: L } = q({
|
|
341
|
+
queryKey: x(u),
|
|
342
|
+
queryFn: () => F(u),
|
|
339
343
|
enabled: n.enabled && v,
|
|
340
|
-
staleTime:
|
|
344
|
+
staleTime: T
|
|
341
345
|
});
|
|
342
|
-
return v ? { options: y ?? [], isLoading: !y &&
|
|
346
|
+
return v ? { options: y ?? [], isLoading: !y && L, localSearch: !1 } : { options: t ?? [], isLoading: !t && k, localSearch: !!u };
|
|
343
347
|
}
|
|
344
|
-
const
|
|
348
|
+
const Ke = 200;
|
|
345
349
|
function Me(n, i, p) {
|
|
346
|
-
return i.trim() ? !n || n.length >=
|
|
350
|
+
return i.trim() ? !n || n.length >= Ke ? !0 : ie(n, i, !0, p).length === 0 : !1;
|
|
347
351
|
}
|
|
348
|
-
function ie(n, i, p,
|
|
349
|
-
return !p || !i.trim() ? n : n.filter((h) => Re(
|
|
352
|
+
function ie(n, i, p, u) {
|
|
353
|
+
return !p || !i.trim() ? n : n.filter((h) => Re(u(h), i));
|
|
350
354
|
}
|
|
351
355
|
function dt({
|
|
352
356
|
relation: n,
|
|
353
357
|
parentId: i,
|
|
354
358
|
allRelations: p,
|
|
355
|
-
extraFilter:
|
|
359
|
+
extraFilter: u,
|
|
356
360
|
optionSort: h,
|
|
357
|
-
requiredParent:
|
|
358
|
-
onCountChange:
|
|
359
|
-
readOnly:
|
|
361
|
+
requiredParent: N,
|
|
362
|
+
onCountChange: _,
|
|
363
|
+
readOnly: F
|
|
360
364
|
}) {
|
|
361
|
-
const x = he(),
|
|
365
|
+
const x = he(), T = Ee(), t = je(), [k, v] = se(!1), [y, L] = se(""), I = p.find(
|
|
362
366
|
(r) => r.many_collection === n.many_collection && r.many_field === n.junction_field && r.id !== n.id
|
|
363
|
-
), s =
|
|
367
|
+
), s = Ae(I), C = n.junction_field ?? "", P = n.many_field ?? "", m = n.one_field ?? `${n.many_collection}.${C}`, { data: o } = q({
|
|
364
368
|
queryKey: ["col-meta", s],
|
|
365
369
|
queryFn: () => x.request(U(`/collections/${s}`)).then((r) => r.data),
|
|
366
370
|
enabled: !!s,
|
|
367
371
|
staleTime: 3e5,
|
|
368
372
|
retry: !1
|
|
369
|
-
}), { data: X = [], isFetching: ae } =
|
|
373
|
+
}), { data: X = [], isFetching: ae } = q({
|
|
370
374
|
queryKey: ["m2m-items", n.many_collection, P, i],
|
|
371
375
|
queryFn: () => x.request(
|
|
372
376
|
U(`/items/${n.many_collection}`, {
|
|
373
377
|
filter: JSON.stringify({ [P]: { _eq: i } }),
|
|
374
378
|
limit: 1,
|
|
375
|
-
fields: `id,${
|
|
379
|
+
fields: `id,${C}`
|
|
376
380
|
})
|
|
377
381
|
).then((r) => r.data ?? []),
|
|
378
382
|
staleTime: 3e4,
|
|
379
383
|
enabled: !!i && i !== "new"
|
|
380
|
-
}),
|
|
384
|
+
}), E = be().isAdmin, R = s === "nivaro_users" ? ge(E) : null, H = xe(s === "nivaro_users"), z = u ? R ? { _and: [u, R] } : u : R, M = z ? JSON.stringify(z) : void 0, Y = h && !/^-?label$/.test(h) ? h : void 0, Z = (() => {
|
|
381
385
|
const r = o == null ? void 0 : o.display_template;
|
|
382
386
|
if (!r || !r.includes(".")) return null;
|
|
383
387
|
const b = [...r.matchAll(/\{\{([^}]+)\}\}/g)].map((le) => le[1].trim());
|
|
384
388
|
return b.length === 0 ? null : ["id", ...b].join(",");
|
|
385
389
|
})(), {
|
|
386
|
-
options:
|
|
387
|
-
isLoading:
|
|
390
|
+
options: B,
|
|
391
|
+
isLoading: G,
|
|
388
392
|
localSearch: ee
|
|
389
|
-
} =
|
|
393
|
+
} = Ue({
|
|
390
394
|
client: x,
|
|
391
395
|
relatedCollection: s,
|
|
392
396
|
search: y,
|
|
393
|
-
filterParam:
|
|
397
|
+
filterParam: M,
|
|
394
398
|
serverSort: Y,
|
|
395
399
|
templateNestedFields: Z,
|
|
396
|
-
enabled:
|
|
400
|
+
enabled: k && !!s,
|
|
397
401
|
labelOf: e
|
|
398
|
-
}),
|
|
399
|
-
$.current =
|
|
402
|
+
}), O = (t == null ? void 0 : t.getStagedLinks(m)) ?? [], K = (t == null ? void 0 : t.getStagedUnlinks(m)) ?? /* @__PURE__ */ new Set(), g = X.find((r) => !K.has(r.id)) ?? null, j = g ? g[C] : null, te = O.length > 0 ? O[O.length - 1] : null, f = te ?? j, ne = O.length > 0 || K.size > 0, $ = fe(_);
|
|
403
|
+
$.current = _, pe(() => {
|
|
400
404
|
var r;
|
|
401
|
-
(r = $.current) == null || r.call($,
|
|
402
|
-
}, [
|
|
403
|
-
const { data:
|
|
404
|
-
queryKey: ["relation-single", s, String(
|
|
405
|
-
queryFn: () =>
|
|
406
|
-
enabled: !!s &&
|
|
405
|
+
(r = $.current) == null || r.call($, f != null ? 1 : 0);
|
|
406
|
+
}, [f]);
|
|
407
|
+
const { data: D } = q({
|
|
408
|
+
queryKey: ["relation-single", s, String(f)],
|
|
409
|
+
queryFn: () => T(s, f),
|
|
410
|
+
enabled: !!s && f != null,
|
|
407
411
|
staleTime: 6e4
|
|
408
|
-
}), J = JSON.stringify(
|
|
409
|
-
queryKey: ["relation-avail", s, String(
|
|
412
|
+
}), J = JSON.stringify(u ? { _and: [{ id: { _eq: f } }, u] } : { id: { _eq: f } }), { data: A } = q({
|
|
413
|
+
queryKey: ["relation-avail", s, String(f), M],
|
|
410
414
|
queryFn: () => x.request(
|
|
411
415
|
U(`/items/${s}`, {
|
|
412
416
|
filter: J,
|
|
@@ -415,67 +419,67 @@ function dt({
|
|
|
415
419
|
fields: "id"
|
|
416
420
|
})
|
|
417
421
|
).then((r) => r.data ?? []),
|
|
418
|
-
enabled: !!s &&
|
|
422
|
+
enabled: !!s && f != null && !!D,
|
|
419
423
|
staleTime: 3e4
|
|
420
|
-
}),
|
|
424
|
+
}), V = A !== void 0 && A.length === 0, w = ze(V);
|
|
421
425
|
function e(r) {
|
|
422
426
|
const b = (o == null ? void 0 : o.display_template) ?? null;
|
|
423
427
|
return b ? Fe(b, r) : String(r.name ?? r.title ?? r.label ?? r.id ?? "");
|
|
424
428
|
}
|
|
425
|
-
const a =
|
|
426
|
-
if (
|
|
427
|
-
return /* @__PURE__ */ l("span", { className: "block truncate text-[12px] text-slate-700 dark:text-slate-200", children:
|
|
428
|
-
function
|
|
429
|
-
for (const b of
|
|
430
|
-
g && !
|
|
429
|
+
const a = B.find((r) => String(r.id) === String(f)) ?? D, c = f != null && !D && !a, S = a ? e(a) : null;
|
|
430
|
+
if (F)
|
|
431
|
+
return /* @__PURE__ */ l("span", { className: "block truncate text-[12px] text-slate-700 dark:text-slate-200", children: c ? "…" : S ?? "—" });
|
|
432
|
+
function $e(r) {
|
|
433
|
+
for (const b of O) t == null || t.unstageLink(m, b);
|
|
434
|
+
g && !K.has(g.id) && (t == null || t.stageUnlink(m, g.id)), String(r) === String(j) && g ? t == null || t.unstageUnlink(m, g.id) : String(r) !== String(f) && (t == null || t.stageLink(m, r)), v(!1), L("");
|
|
431
435
|
}
|
|
432
|
-
function
|
|
433
|
-
for (const r of
|
|
434
|
-
g && (t == null || t.stageUnlink(
|
|
436
|
+
function De() {
|
|
437
|
+
for (const r of O) t == null || t.unstageLink(m, r);
|
|
438
|
+
g && (t == null || t.stageUnlink(m, g.id)), v(!1);
|
|
435
439
|
}
|
|
436
|
-
return
|
|
440
|
+
return N ? /* @__PURE__ */ d(
|
|
437
441
|
"button",
|
|
438
442
|
{
|
|
439
443
|
type: "button",
|
|
440
444
|
disabled: !0,
|
|
441
445
|
className: "w-full h-9 px-3 text-[12px] border border-input rounded-md bg-background text-left flex items-center justify-between opacity-50 cursor-not-allowed",
|
|
442
446
|
children: [
|
|
443
|
-
/* @__PURE__ */
|
|
447
|
+
/* @__PURE__ */ d("span", { className: "truncate text-muted-foreground", children: [
|
|
444
448
|
"Select ",
|
|
445
|
-
|
|
449
|
+
N,
|
|
446
450
|
" first"
|
|
447
451
|
] }),
|
|
448
452
|
/* @__PURE__ */ l(re, { className: "h-4 w-4 shrink-0 opacity-50" })
|
|
449
453
|
]
|
|
450
454
|
}
|
|
451
|
-
) : /* @__PURE__ */
|
|
452
|
-
/* @__PURE__ */
|
|
455
|
+
) : /* @__PURE__ */ d("div", { ...w.bind, children: [
|
|
456
|
+
/* @__PURE__ */ d(
|
|
453
457
|
Ce,
|
|
454
458
|
{
|
|
455
|
-
open:
|
|
459
|
+
open: k,
|
|
456
460
|
onOpenChange: (r) => {
|
|
457
|
-
v(r), r ||
|
|
461
|
+
v(r), r || L("");
|
|
458
462
|
},
|
|
459
463
|
children: [
|
|
460
|
-
/* @__PURE__ */ l(
|
|
464
|
+
/* @__PURE__ */ l(Oe, { asChild: !0, children: /* @__PURE__ */ d(
|
|
461
465
|
"button",
|
|
462
466
|
{
|
|
463
467
|
type: "button",
|
|
464
|
-
className:
|
|
468
|
+
className: Q(
|
|
465
469
|
"w-full h-9 px-3 text-[12px] border rounded-md bg-background text-left flex items-center justify-between hover:bg-muted cursor-pointer transition-colors disabled:pointer-events-none disabled:opacity-50",
|
|
466
|
-
|
|
470
|
+
V ? "border-amber-300 dark:border-amber-600" : ne ? "border-nvr-cyan/50" : "border-input"
|
|
467
471
|
),
|
|
468
472
|
children: [
|
|
469
|
-
|
|
473
|
+
c || ae && te == null && i !== "new" ? /* @__PURE__ */ l(ce, { className: "h-3.5 w-3.5 animate-spin text-muted-foreground" }) : /* @__PURE__ */ d(
|
|
470
474
|
"span",
|
|
471
475
|
{
|
|
472
|
-
className:
|
|
476
|
+
className: Q(
|
|
473
477
|
"flex items-center gap-1.5 truncate min-w-0",
|
|
474
|
-
|
|
478
|
+
S ? ne ? "text-nvr-cyan" : "text-slate-800 dark:text-slate-100" : "text-muted-foreground"
|
|
475
479
|
),
|
|
476
480
|
children: [
|
|
477
|
-
|
|
478
|
-
/* @__PURE__ */ l("span", { className: "truncate", children:
|
|
481
|
+
V && /* @__PURE__ */ l(ue, { className: "h-3.5 w-3.5 shrink-0 text-amber-500" }),
|
|
482
|
+
/* @__PURE__ */ l("span", { className: "truncate", children: S ?? "Select…" })
|
|
479
483
|
]
|
|
480
484
|
}
|
|
481
485
|
),
|
|
@@ -483,22 +487,22 @@ function dt({
|
|
|
483
487
|
]
|
|
484
488
|
}
|
|
485
489
|
) }),
|
|
486
|
-
/* @__PURE__ */ l(
|
|
490
|
+
/* @__PURE__ */ l(qe, { className: "w-[320px] p-0", align: "start", children: /* @__PURE__ */ d(ke, { shouldFilter: !1, children: [
|
|
487
491
|
/* @__PURE__ */ l(
|
|
488
|
-
|
|
492
|
+
we,
|
|
489
493
|
{
|
|
490
494
|
placeholder: "Search…",
|
|
491
495
|
value: y,
|
|
492
|
-
onValueChange:
|
|
496
|
+
onValueChange: L,
|
|
493
497
|
className: "h-9 text-[12px]"
|
|
494
498
|
}
|
|
495
499
|
),
|
|
496
|
-
|
|
500
|
+
f != null && /* @__PURE__ */ d(
|
|
497
501
|
"button",
|
|
498
502
|
{
|
|
499
503
|
type: "button",
|
|
500
504
|
onClick: () => {
|
|
501
|
-
|
|
505
|
+
De(), v(!1);
|
|
502
506
|
},
|
|
503
507
|
className: "flex w-full items-center gap-2 px-3 py-1.5 text-[13px] text-slate-500 hover:bg-muted border-b border-slate-100 dark:text-slate-400 dark:border-border",
|
|
504
508
|
children: [
|
|
@@ -507,23 +511,23 @@ function dt({
|
|
|
507
511
|
]
|
|
508
512
|
}
|
|
509
513
|
),
|
|
510
|
-
/* @__PURE__ */
|
|
511
|
-
|
|
512
|
-
!
|
|
514
|
+
/* @__PURE__ */ d(Se, { children: [
|
|
515
|
+
G ? /* @__PURE__ */ l("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ l(ce, { className: "h-4 w-4 animate-spin text-muted-foreground" }) }) : /* @__PURE__ */ l(Ne, { className: "py-3 text-left text-[12px] text-muted-foreground px-3", children: "No results" }),
|
|
516
|
+
!G && /* @__PURE__ */ l(_e, { children: [...ie(B, y, ee, e)].sort(
|
|
513
517
|
(r, b) => Y ? 0 : ye(e(r), e(b), y, h === "-label")
|
|
514
518
|
).map((r) => {
|
|
515
|
-
const b = String(r.id), le = String(
|
|
516
|
-
return /* @__PURE__ */
|
|
519
|
+
const b = String(r.id), le = String(f) === b;
|
|
520
|
+
return /* @__PURE__ */ d(
|
|
517
521
|
Le,
|
|
518
522
|
{
|
|
519
523
|
value: b,
|
|
520
|
-
onSelect: () =>
|
|
524
|
+
onSelect: () => $e(r.id),
|
|
521
525
|
className: "flex items-center gap-2 text-[12px]",
|
|
522
526
|
children: [
|
|
523
527
|
/* @__PURE__ */ l(
|
|
524
528
|
"div",
|
|
525
529
|
{
|
|
526
|
-
className:
|
|
530
|
+
className: Q(
|
|
527
531
|
"flex h-4 w-4 shrink-0 items-center justify-center rounded-full border transition-colors",
|
|
528
532
|
le ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300 dark:border-slate-500"
|
|
529
533
|
),
|
|
@@ -556,7 +560,7 @@ function dt({
|
|
|
556
560
|
]
|
|
557
561
|
}
|
|
558
562
|
),
|
|
559
|
-
|
|
563
|
+
w.tip
|
|
560
564
|
] });
|
|
561
565
|
}
|
|
562
566
|
export {
|
|
@@ -564,7 +568,7 @@ export {
|
|
|
564
568
|
dt as M2MSingleSelectCombobox,
|
|
565
569
|
ot as m2aWriteMeta,
|
|
566
570
|
Me as m2mAsksServer,
|
|
567
|
-
|
|
571
|
+
W as m2mIdKey,
|
|
568
572
|
ie as narrowM2MOptions,
|
|
569
|
-
|
|
573
|
+
Ae as resolveM2MRelatedCollection
|
|
570
574
|
};
|