@nivaro/react 0.3.111 → 0.3.112
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 +170 -2
- package/dist/index.js +745 -728
- package/dist/shared/components/CollectionBrowserView.js +3097 -2972
- package/dist/shared/components/CollectionImportBanner.js +135 -0
- package/dist/shared/components/ItemEditForm.js +2235 -2218
- package/dist/shared/components/JobsTray.js +54 -47
- package/dist/shared/components/ViewAsPersonButton.js +109 -0
- package/dist/shared/components/bulk/BulkFieldUpdate.js +228 -150
- package/dist/shared/components/bulk/BulkFieldUpdateButton.js +35 -41
- package/dist/shared/components/bulk/BulkLinksValue.js +91 -0
- package/dist/shared/components/bulk/bulk-field-options.js +20 -19
- package/dist/shared/components/bulk/bulk-update-preview.js +39 -0
- package/dist/shared/components/cbv/ColumnHeaderMenu.js +113 -0
- package/dist/shared/components/cbv/column-totals.js +66 -0
- package/dist/shared/components/collections-directory/CollectionHoverCard.js +108 -81
- package/dist/shared/components/collections-directory/CollectionRow.js +164 -148
- package/dist/shared/components/collections-directory/CollectionsDirectory.js +167 -166
- package/dist/shared/components/collections-directory/directory-data.js +70 -58
- package/dist/shared/components/imports/CollectionImportPanel.js +120 -118
- package/dist/shared/components/imports/DefinitionsPanel.js +24 -24
- package/dist/shared/components/imports/ImportDuplicatesNotice.js +65 -0
- package/dist/shared/components/item-edit/CatalogPickerField.js +631 -639
- package/dist/shared/components/item-edit/DuplicateNotice.js +168 -0
- package/dist/shared/components/item-edit/FieldRow.js +248 -246
- package/dist/shared/components/item-edit/InlineGridField.js +34 -33
- package/dist/shared/components/item-edit/InlineTableField.js +3064 -2882
- package/dist/shared/components/item-edit/MembershipSetField.js +165 -169
- package/dist/shared/components/item-edit/NestedRelationEditor.js +184 -189
- package/dist/shared/components/item-edit/PlanGrid.js +2 -1
- package/dist/shared/components/item-edit/QuickPickerDialog.js +35 -34
- package/dist/shared/components/item-edit/RecordLiveSync.js +32 -30
- package/dist/shared/components/item-edit/RelationCombobox.js +101 -100
- package/dist/shared/components/item-edit/RowHistorySheet.js +28 -27
- package/dist/shared/components/item-edit/SummaryPanel.js +133 -135
- package/dist/shared/components/item-edit/ViewAsRole.js +129 -52
- package/dist/shared/components/item-edit/grid-search.js +345 -0
- package/dist/shared/components/item-edit/render-stability.js +61 -54
- package/dist/shared/components/notifications/NotificationRulesEditor.js +25 -20
- package/dist/shared/components/ops-report/DigestSections.js +163 -144
- package/dist/shared/components/ops-report/drill.js +97 -97
- package/dist/shared/components/panels/AddendumLinesDiff.js +52 -51
- package/dist/shared/components/panels/AddendumPanel.js +92 -91
- package/dist/shared/components/panels/AsyncUserPicker.js +108 -0
- package/dist/shared/components/panels/CommentPanel.js +265 -252
- package/dist/shared/components/panels/OwnersSlot.js +47 -35
- package/dist/shared/components/panels/PipelineInsight.js +186 -0
- package/dist/shared/components/panels/PipelinePanel.js +1529 -1492
- package/dist/shared/components/panels/RecordIntegrityBanner.js +39 -38
- package/dist/shared/components/panels/RevisionsPanel.js +261 -260
- package/dist/shared/components/pipeline/FieldPicker.js +41 -40
- package/dist/shared/components/pipeline/OwnerMatrix.js +829 -700
- package/dist/shared/components/pipeline/OwnerRecordTrial.js +362 -0
- package/dist/shared/components/pipeline/PipelineEditorView.js +483 -467
- package/dist/shared/components/pipeline/PipelineStateOwners.js +65 -64
- package/dist/shared/components/pipeline/owner-matrix-draft.js +178 -0
- package/dist/shared/components/profile/MyDefaultsCard.js +36 -35
- package/dist/shared/components/profile/PersonHeader.js +29 -29
- package/dist/shared/components/profile/PersonProfile.js +30 -28
- package/dist/shared/components/profile/SlowScreensCard.js +286 -0
- package/dist/shared/components/queue/QueueWorklist.js +1090 -1071
- package/dist/shared/components/quick-filters/useQuickFilterEditing.js +45 -44
- package/dist/shared/components/support/TicketDetailSheet.js +25 -16
- package/dist/shared/components/support/TicketSlowScreens.js +32 -0
- package/dist/shared/lib/activity-sentence.js +224 -178
- package/dist/shared/lib/collection-import-banner.js +27 -0
- package/dist/shared/lib/crash-report.js +112 -0
- package/dist/shared/lib/export-runs.js +99 -0
- package/dist/shared/lib/jobs-tray.js +89 -67
- package/dist/shared/lib/list-link.js +76 -69
- package/dist/shared/lib/nav-trail.js +180 -76
- package/dist/shared/lib/query-keys.js +26 -0
- package/dist/shared/lib/view-as.js +16 -11
- package/package.json +1 -1
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
import { jsxs as a, jsx as e, Fragment as y } from "react/jsx-runtime";
|
|
2
|
+
import { useQuery as O, keepPreviousData as W } from "@tanstack/react-query";
|
|
3
|
+
import { FlaskConical as A, Loader2 as T, AlertTriangle as q, Search as S, ChevronDown as J, ArrowRight as D, Check as K, X as L, HelpCircle as Q } from "lucide-react";
|
|
4
|
+
import { useState as g, useEffect as k, useMemo as $, useRef as U } from "react";
|
|
5
|
+
import { useNivaroClient as R } from "../../context.js";
|
|
6
|
+
import { post as B, get as G } from "../../lib/commands.js";
|
|
7
|
+
import { cn as w } from "../../lib/utils.js";
|
|
8
|
+
import { ErrorNotice as H } from "../ErrorNotice.js";
|
|
9
|
+
import { Popover as F, PopoverTrigger as P, PopoverContent as j } from "../ui/popover.js";
|
|
10
|
+
import { extractTemplateFields as I, renderDisplayTemplate as M } from "./relations.js";
|
|
11
|
+
function E(t, s) {
|
|
12
|
+
const [n, r] = g(t);
|
|
13
|
+
return k(() => {
|
|
14
|
+
const p = setTimeout(() => r(t), s);
|
|
15
|
+
return () => clearTimeout(p);
|
|
16
|
+
}, [t, s]), n;
|
|
17
|
+
}
|
|
18
|
+
function me({
|
|
19
|
+
templateId: t,
|
|
20
|
+
collections: s,
|
|
21
|
+
draft: n,
|
|
22
|
+
displayTemplates: r = {}
|
|
23
|
+
}) {
|
|
24
|
+
const p = R(), [d, u] = g(s[0] ?? ""), [l, b] = g(null);
|
|
25
|
+
k(() => {
|
|
26
|
+
s.includes(d) || u(s[0] ?? "");
|
|
27
|
+
}, [s, d]);
|
|
28
|
+
const f = $(() => n && n.length > 0 ? JSON.stringify(n) : "", [n]), x = E(f, 400), c = O({
|
|
29
|
+
queryKey: ["owner-preview", t, d, (l == null ? void 0 : l.id) ?? "", x],
|
|
30
|
+
queryFn: () => p.request(
|
|
31
|
+
B(`/pipelines/${t}/owner-preview`, {
|
|
32
|
+
collection: d,
|
|
33
|
+
item: l == null ? void 0 : l.id,
|
|
34
|
+
...x ? { draft: JSON.parse(x) } : {}
|
|
35
|
+
})
|
|
36
|
+
).then((h) => h.data),
|
|
37
|
+
enabled: !!l && !!d,
|
|
38
|
+
placeholderData: W,
|
|
39
|
+
staleTime: 15e3
|
|
40
|
+
}), o = c.data && c.data.item === (l == null ? void 0 : l.id) ? c.data : null, N = f !== x || c.isFetching;
|
|
41
|
+
return s.length === 0 ? null : /* @__PURE__ */ a(
|
|
42
|
+
"section",
|
|
43
|
+
{
|
|
44
|
+
"data-owner-trial": !0,
|
|
45
|
+
className: "space-y-3 rounded-lg border border-slate-200 bg-slate-50/60 px-4 py-3 dark:border-border dark:bg-muted/30",
|
|
46
|
+
children: [
|
|
47
|
+
/* @__PURE__ */ a("div", { className: "flex flex-wrap items-center gap-x-3 gap-y-2", children: [
|
|
48
|
+
/* @__PURE__ */ a("span", { className: "flex items-center gap-1.5 text-[12px] font-semibold text-slate-700 dark:text-slate-200", children: [
|
|
49
|
+
/* @__PURE__ */ e(A, { className: "h-3.5 w-3.5 text-nvr-cyan" }),
|
|
50
|
+
"Try a record"
|
|
51
|
+
] }),
|
|
52
|
+
s.length > 1 && /* @__PURE__ */ e("div", { className: "flex items-center rounded-md border border-slate-200 bg-white p-0.5 dark:border-border dark:bg-card", children: s.map((h) => /* @__PURE__ */ e(
|
|
53
|
+
"button",
|
|
54
|
+
{
|
|
55
|
+
type: "button",
|
|
56
|
+
onClick: () => {
|
|
57
|
+
u(h), b(null);
|
|
58
|
+
},
|
|
59
|
+
className: w(
|
|
60
|
+
"h-6 rounded px-2 text-[11px] font-medium transition-colors",
|
|
61
|
+
h === d ? "bg-nvr-cyan/10 text-nvr-cyan" : "text-slate-500 hover:text-slate-800 dark:text-slate-400 dark:hover:text-slate-200"
|
|
62
|
+
),
|
|
63
|
+
children: h
|
|
64
|
+
},
|
|
65
|
+
h
|
|
66
|
+
)) }),
|
|
67
|
+
/* @__PURE__ */ e(
|
|
68
|
+
ee,
|
|
69
|
+
{
|
|
70
|
+
collection: d,
|
|
71
|
+
displayTemplate: r[d] ?? null,
|
|
72
|
+
value: l,
|
|
73
|
+
onChange: b
|
|
74
|
+
}
|
|
75
|
+
),
|
|
76
|
+
l && /* @__PURE__ */ e("span", { className: "text-[11.5px] text-slate-500 dark:text-slate-400", children: n && n.length > 0 ? /* @__PURE__ */ a(y, { children: [
|
|
77
|
+
"Comparing the saved matrix with",
|
|
78
|
+
" ",
|
|
79
|
+
/* @__PURE__ */ e("span", { className: "font-medium text-violet-700 dark:text-violet-300", children: "your draft" })
|
|
80
|
+
] }) : "Under the saved matrix" }),
|
|
81
|
+
l && N && /* @__PURE__ */ e(T, { className: "h-3.5 w-3.5 animate-spin text-slate-400" }),
|
|
82
|
+
o && o.unowned > 0 && /* @__PURE__ */ a("span", { className: "ml-auto inline-flex items-center gap-1 rounded-full bg-amber-100 px-2 py-0.5 text-[11px] font-semibold text-amber-800 dark:bg-amber-500/15 dark:text-amber-300", children: [
|
|
83
|
+
/* @__PURE__ */ e(q, { className: "h-3 w-3" }),
|
|
84
|
+
o.unowned,
|
|
85
|
+
" step",
|
|
86
|
+
o.unowned === 1 ? "" : "s",
|
|
87
|
+
" with no assigned owner"
|
|
88
|
+
] })
|
|
89
|
+
] }),
|
|
90
|
+
!l && /* @__PURE__ */ e("p", { className: "text-[12px] text-slate-500 dark:text-slate-400", children: "Pick a real record to see who would own each of its steps — and which steps nobody would. Edit the matrix in Draft mode and the answer follows your changes before you save them." }),
|
|
91
|
+
l && c.isError && /* @__PURE__ */ e(
|
|
92
|
+
H,
|
|
93
|
+
{
|
|
94
|
+
error: c.error,
|
|
95
|
+
what: "the owner preview",
|
|
96
|
+
onRetry: () => void c.refetch()
|
|
97
|
+
}
|
|
98
|
+
),
|
|
99
|
+
o && /* @__PURE__ */ a(y, { children: [
|
|
100
|
+
!o.has_instance && /* @__PURE__ */ e("p", { className: "text-[11.5px] text-slate-500 dark:text-slate-400", children: "This record has not started the pipeline yet — every step is shown as it would resolve today." }),
|
|
101
|
+
/* @__PURE__ */ e(V, { steps: o.steps })
|
|
102
|
+
] })
|
|
103
|
+
]
|
|
104
|
+
}
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
function V({ steps: t }) {
|
|
108
|
+
return /* @__PURE__ */ e("ol", { className: "flex gap-2 overflow-x-auto pb-1", "aria-label": "Owners per step", children: t.map((s) => /* @__PURE__ */ e(X, { step: s }, s.state.id)) });
|
|
109
|
+
}
|
|
110
|
+
function X({ step: t }) {
|
|
111
|
+
const s = t.draft ?? t.saved, n = t.state.is_terminal, r = s.no_assigned_owner && !n;
|
|
112
|
+
return /* @__PURE__ */ a(
|
|
113
|
+
"li",
|
|
114
|
+
{
|
|
115
|
+
"data-step": t.state.key,
|
|
116
|
+
"data-no-owner": r ? "true" : void 0,
|
|
117
|
+
className: w(
|
|
118
|
+
"flex w-[208px] shrink-0 flex-col gap-2 rounded-lg border bg-white p-2.5 dark:bg-card",
|
|
119
|
+
r ? "border-amber-300 dark:border-amber-500/40" : t.changed ? "border-violet-300 dark:border-violet-500/40" : "border-slate-200 dark:border-border",
|
|
120
|
+
t.state.is_current && "ring-2 ring-nvr-cyan/40"
|
|
121
|
+
),
|
|
122
|
+
children: [
|
|
123
|
+
/* @__PURE__ */ a("div", { className: "flex items-start gap-1.5", children: [
|
|
124
|
+
/* @__PURE__ */ e(
|
|
125
|
+
"span",
|
|
126
|
+
{
|
|
127
|
+
className: "mt-1 h-2 w-2 shrink-0 rounded-full",
|
|
128
|
+
style: { backgroundColor: t.state.color ?? "#94a3b8" }
|
|
129
|
+
}
|
|
130
|
+
),
|
|
131
|
+
/* @__PURE__ */ e("span", { className: "line-clamp-2 min-w-0 flex-1 break-words text-[12px] font-semibold leading-tight text-slate-800 dark:text-slate-100", children: t.state.label }),
|
|
132
|
+
t.state.is_current && /* @__PURE__ */ e("span", { className: "shrink-0 rounded bg-nvr-cyan/10 px-1 py-px text-[9.5px] font-semibold uppercase tracking-wide text-nvr-cyan", children: "Now" }),
|
|
133
|
+
t.changed && /* @__PURE__ */ e("span", { className: "shrink-0 rounded bg-violet-100 px-1 py-px text-[9.5px] font-semibold uppercase tracking-wide text-violet-700 dark:bg-violet-500/15 dark:text-violet-300", children: "Draft" })
|
|
134
|
+
] }),
|
|
135
|
+
n ? /* @__PURE__ */ e("p", { className: "text-[11px] text-slate-400 dark:text-slate-500", children: "Final step — no owner" }) : /* @__PURE__ */ e(z, { owners: s.owners, notRequired: t.state.owners_not_required }),
|
|
136
|
+
r && /* @__PURE__ */ a("p", { className: "flex items-start gap-1 rounded-md bg-amber-50 px-1.5 py-1 text-[11px] font-medium leading-snug text-amber-800 dark:bg-amber-500/10 dark:text-amber-300", children: [
|
|
137
|
+
/* @__PURE__ */ e(q, { className: "mt-px h-3 w-3 shrink-0" }),
|
|
138
|
+
s.owners.some((p) => p.via === "stand_in") ? "No assigned owner — only a stand-in" : "No owner"
|
|
139
|
+
] }),
|
|
140
|
+
t.changed && /* @__PURE__ */ a("p", { className: "flex flex-wrap items-center gap-1 text-[10.5px] text-slate-500 dark:text-slate-400", children: [
|
|
141
|
+
/* @__PURE__ */ e("span", { children: "Saved:" }),
|
|
142
|
+
/* @__PURE__ */ e("span", { className: "line-through decoration-slate-400", children: t.saved.owners.length > 0 ? t.saved.owners.map((p) => p.name).join(", ") : "nobody" }),
|
|
143
|
+
/* @__PURE__ */ e(D, { className: "h-3 w-3" }),
|
|
144
|
+
/* @__PURE__ */ e("span", { className: "font-medium text-violet-700 dark:text-violet-300", children: "draft" })
|
|
145
|
+
] }),
|
|
146
|
+
!n && /* @__PURE__ */ e(Y, { step: t })
|
|
147
|
+
]
|
|
148
|
+
}
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
function z({ owners: t, notRequired: s }) {
|
|
152
|
+
if (t.length === 0)
|
|
153
|
+
return /* @__PURE__ */ e("p", { className: "text-[11px] text-slate-400 dark:text-slate-500", children: s ? "Nobody — this step needs no owner" : "Nobody" });
|
|
154
|
+
const n = t.slice(0, 5);
|
|
155
|
+
return /* @__PURE__ */ a("div", { className: "flex flex-wrap gap-1", children: [
|
|
156
|
+
n.map((r) => /* @__PURE__ */ a(
|
|
157
|
+
"span",
|
|
158
|
+
{
|
|
159
|
+
"data-tip": r.via === "stand_in" ? "Stands in from the record: it waits in their queue, but only an assigned owner can approve" : r.delegate_for ? `Covering for ${r.delegate_for} (out of office)` : r.via === "manual" ? "Added to this record by hand" : r.email ?? void 0,
|
|
160
|
+
className: w(
|
|
161
|
+
"inline-flex max-w-full items-center gap-1 rounded-full px-1.5 py-0.5 text-[11px] font-medium",
|
|
162
|
+
r.via === "stand_in" ? "border border-dashed border-amber-400 text-amber-800 dark:border-amber-500/50 dark:text-amber-300" : "bg-nvr-cyan/10 text-slate-700 dark:bg-nvr-cyan/15 dark:text-slate-200",
|
|
163
|
+
r.inactive && "line-through opacity-60"
|
|
164
|
+
),
|
|
165
|
+
children: [
|
|
166
|
+
/* @__PURE__ */ e("span", { className: "truncate", children: r.name }),
|
|
167
|
+
r.via === "stand_in" && /* @__PURE__ */ e("span", { className: "shrink-0 text-[9.5px] uppercase", children: "stand-in" }),
|
|
168
|
+
r.delegate_for && /* @__PURE__ */ a("span", { className: "shrink-0 text-[9.5px] text-slate-500 dark:text-slate-400", children: [
|
|
169
|
+
"for ",
|
|
170
|
+
r.delegate_for
|
|
171
|
+
] })
|
|
172
|
+
]
|
|
173
|
+
},
|
|
174
|
+
r.id
|
|
175
|
+
)),
|
|
176
|
+
t.length > n.length && /* @__PURE__ */ a("span", { className: "px-1 text-[11px] text-slate-400", children: [
|
|
177
|
+
"+",
|
|
178
|
+
t.length - n.length
|
|
179
|
+
] })
|
|
180
|
+
] });
|
|
181
|
+
}
|
|
182
|
+
function v({ title: t, owners: s }) {
|
|
183
|
+
const n = s.match.group;
|
|
184
|
+
return /* @__PURE__ */ a("div", { className: "space-y-1.5", children: [
|
|
185
|
+
t && /* @__PURE__ */ e("p", { className: "text-[10px] font-semibold uppercase tracking-wide text-slate-400", children: t }),
|
|
186
|
+
n && /* @__PURE__ */ a("p", { className: "flex flex-wrap items-center gap-1 text-[12px] font-medium text-slate-800 dark:text-slate-100", children: [
|
|
187
|
+
n.is_default ? "Default group" : "Owner group",
|
|
188
|
+
n.name ? /* @__PURE__ */ a("span", { children: [
|
|
189
|
+
"“",
|
|
190
|
+
n.name,
|
|
191
|
+
"”"
|
|
192
|
+
] }) : null,
|
|
193
|
+
n.is_draft && /* @__PURE__ */ e("span", { className: "rounded bg-violet-100 px-1 text-[9.5px] font-semibold uppercase text-violet-700 dark:bg-violet-500/15 dark:text-violet-300", children: "draft" })
|
|
194
|
+
] }),
|
|
195
|
+
s.match.facts.length > 0 && /* @__PURE__ */ a("table", { className: "w-full text-[11px]", children: [
|
|
196
|
+
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */ a("tr", { className: "text-left text-slate-400", children: [
|
|
197
|
+
/* @__PURE__ */ e("th", { className: "pb-0.5 font-medium", children: "Dimension" }),
|
|
198
|
+
/* @__PURE__ */ e("th", { className: "pb-0.5 font-medium", children: "Group wants" }),
|
|
199
|
+
/* @__PURE__ */ e("th", { className: "pb-0.5 font-medium", children: "Record has" })
|
|
200
|
+
] }) }),
|
|
201
|
+
/* @__PURE__ */ e("tbody", { children: s.match.facts.map((r) => /* @__PURE__ */ a("tr", { className: "text-slate-700 dark:text-slate-200", children: [
|
|
202
|
+
/* @__PURE__ */ e("td", { className: "py-0.5 pr-2", children: r.label }),
|
|
203
|
+
/* @__PURE__ */ e("td", { className: "py-0.5 pr-2", children: r.wants || "—" }),
|
|
204
|
+
/* @__PURE__ */ e("td", { className: "py-0.5", children: r.record_value || "—" })
|
|
205
|
+
] }, r.field)) })
|
|
206
|
+
] }),
|
|
207
|
+
/* @__PURE__ */ e("ul", { className: "space-y-1", children: s.why.map((r) => /* @__PURE__ */ e("li", { className: "text-[11.5px] leading-snug text-slate-600 dark:text-slate-300", children: r }, r)) })
|
|
208
|
+
] });
|
|
209
|
+
}
|
|
210
|
+
function Y({ step: t }) {
|
|
211
|
+
return /* @__PURE__ */ a(F, { children: [
|
|
212
|
+
/* @__PURE__ */ e(P, { asChild: !0, children: /* @__PURE__ */ a(
|
|
213
|
+
"button",
|
|
214
|
+
{
|
|
215
|
+
type: "button",
|
|
216
|
+
className: "mt-auto inline-flex items-center gap-1 self-start text-[11px] font-medium text-slate-500 hover:text-nvr-cyan dark:text-slate-400",
|
|
217
|
+
children: [
|
|
218
|
+
/* @__PURE__ */ e(Q, { className: "h-3 w-3" }),
|
|
219
|
+
"Why?"
|
|
220
|
+
]
|
|
221
|
+
}
|
|
222
|
+
) }),
|
|
223
|
+
/* @__PURE__ */ a(j, { align: "start", className: "w-80 space-y-3 p-3", sideOffset: 4, children: [
|
|
224
|
+
/* @__PURE__ */ e("p", { className: "text-[12.5px] font-semibold text-slate-800 dark:text-slate-100", children: t.state.label }),
|
|
225
|
+
t.draft ? /* @__PURE__ */ a(y, { children: [
|
|
226
|
+
/* @__PURE__ */ e(v, { title: "With your draft", owners: t.draft }),
|
|
227
|
+
t.changed && /* @__PURE__ */ e("div", { className: "border-t border-slate-100 pt-2 dark:border-border", children: /* @__PURE__ */ e(v, { title: "Saved matrix", owners: t.saved }) })
|
|
228
|
+
] }) : /* @__PURE__ */ e(v, { owners: t.saved })
|
|
229
|
+
] })
|
|
230
|
+
] });
|
|
231
|
+
}
|
|
232
|
+
const Z = /^[0-9]+$|^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
233
|
+
function ee({
|
|
234
|
+
collection: t,
|
|
235
|
+
displayTemplate: s,
|
|
236
|
+
value: n,
|
|
237
|
+
onChange: r
|
|
238
|
+
}) {
|
|
239
|
+
const p = R(), [d, u] = g(!1), [l, b] = g(""), f = E(l.trim(), 300), x = U(null);
|
|
240
|
+
k(() => {
|
|
241
|
+
d ? setTimeout(() => {
|
|
242
|
+
var i;
|
|
243
|
+
return (i = x.current) == null ? void 0 : i.focus();
|
|
244
|
+
}, 50) : b("");
|
|
245
|
+
}, [d]);
|
|
246
|
+
const c = $(() => {
|
|
247
|
+
const i = I(s).filter((m) => !m.includes("."));
|
|
248
|
+
return i.length > 0 ? ["id", ...i].join(",") : void 0;
|
|
249
|
+
}, [s]), { data: o = [], isFetching: N } = O({
|
|
250
|
+
queryKey: ["owner-trial-records", t, f, c ?? ""],
|
|
251
|
+
queryFn: () => p.request(
|
|
252
|
+
G(`/items/${t}`, {
|
|
253
|
+
limit: 20,
|
|
254
|
+
sort: "-id",
|
|
255
|
+
...f ? { search: f } : {},
|
|
256
|
+
...c ? { fields: c } : {}
|
|
257
|
+
})
|
|
258
|
+
).then((i) => i.data ?? []),
|
|
259
|
+
enabled: d && !!t,
|
|
260
|
+
staleTime: 3e4
|
|
261
|
+
}), h = (i) => {
|
|
262
|
+
const m = s ? M(s, i) : "";
|
|
263
|
+
return m != null && m.trim() ? `${m} · #${String(i.id)}` : `#${String(i.id)}`;
|
|
264
|
+
}, C = Z.test(l.trim()) && !o.some((i) => String(i.id) === l.trim());
|
|
265
|
+
return /* @__PURE__ */ a("div", { className: "flex items-center gap-1", children: [
|
|
266
|
+
/* @__PURE__ */ a(F, { open: d, onOpenChange: u, children: [
|
|
267
|
+
/* @__PURE__ */ e(P, { asChild: !0, children: /* @__PURE__ */ a(
|
|
268
|
+
"button",
|
|
269
|
+
{
|
|
270
|
+
type: "button",
|
|
271
|
+
className: w(
|
|
272
|
+
"flex h-7 max-w-[320px] items-center gap-1 rounded-md border px-2.5 text-[12px] transition-colors",
|
|
273
|
+
n ? "border-nvr-cyan/50 bg-nvr-cyan/5 font-medium text-nvr-cyan" : "border-slate-200 bg-white text-slate-600 hover:border-slate-300 dark:border-border dark:bg-card dark:text-slate-300"
|
|
274
|
+
),
|
|
275
|
+
children: [
|
|
276
|
+
/* @__PURE__ */ e(S, { className: "h-3 w-3 shrink-0 opacity-60" }),
|
|
277
|
+
/* @__PURE__ */ e("span", { className: "truncate", children: n ? n.label : "Pick a record…" }),
|
|
278
|
+
/* @__PURE__ */ e(J, { className: "h-3 w-3 shrink-0 opacity-50" })
|
|
279
|
+
]
|
|
280
|
+
}
|
|
281
|
+
) }),
|
|
282
|
+
/* @__PURE__ */ a(j, { align: "start", className: "w-80 p-0", sideOffset: 4, children: [
|
|
283
|
+
/* @__PURE__ */ e("div", { className: "border-b border-slate-100 px-2 py-1.5 dark:border-border", children: /* @__PURE__ */ a("div", { className: "relative", children: [
|
|
284
|
+
/* @__PURE__ */ e(S, { className: "absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-slate-400" }),
|
|
285
|
+
/* @__PURE__ */ e(
|
|
286
|
+
"input",
|
|
287
|
+
{
|
|
288
|
+
ref: x,
|
|
289
|
+
value: l,
|
|
290
|
+
onChange: (i) => b(i.target.value),
|
|
291
|
+
placeholder: `Search ${t} or type an id…`,
|
|
292
|
+
className: "h-7 w-full rounded-md bg-slate-50 pl-7 pr-2 text-[12px] placeholder-slate-400 focus:outline-none focus:ring-1 focus:ring-nvr-cyan/40 dark:bg-muted"
|
|
293
|
+
}
|
|
294
|
+
)
|
|
295
|
+
] }) }),
|
|
296
|
+
/* @__PURE__ */ a("div", { className: "max-h-64 overflow-y-auto py-1", children: [
|
|
297
|
+
C && /* @__PURE__ */ a(
|
|
298
|
+
"button",
|
|
299
|
+
{
|
|
300
|
+
type: "button",
|
|
301
|
+
onClick: () => {
|
|
302
|
+
r({ id: l.trim(), label: `#${l.trim()}` }), u(!1);
|
|
303
|
+
},
|
|
304
|
+
className: "flex w-full items-center gap-2 px-3 py-1.5 text-left text-[12px] text-slate-700 hover:bg-muted dark:text-slate-200",
|
|
305
|
+
children: [
|
|
306
|
+
/* @__PURE__ */ e(D, { className: "h-3.5 w-3.5 shrink-0 text-nvr-cyan" }),
|
|
307
|
+
"Use record #",
|
|
308
|
+
l.trim()
|
|
309
|
+
]
|
|
310
|
+
}
|
|
311
|
+
),
|
|
312
|
+
o.map((i) => {
|
|
313
|
+
const m = String(i.id), _ = h(i);
|
|
314
|
+
return /* @__PURE__ */ a(
|
|
315
|
+
"button",
|
|
316
|
+
{
|
|
317
|
+
type: "button",
|
|
318
|
+
onClick: () => {
|
|
319
|
+
r({ id: m, label: _ }), u(!1);
|
|
320
|
+
},
|
|
321
|
+
className: "flex w-full items-center gap-2 px-3 py-1.5 text-left text-[12px] text-slate-700 hover:bg-muted dark:text-slate-200",
|
|
322
|
+
children: [
|
|
323
|
+
/* @__PURE__ */ e(
|
|
324
|
+
K,
|
|
325
|
+
{
|
|
326
|
+
className: w(
|
|
327
|
+
"h-3.5 w-3.5 shrink-0",
|
|
328
|
+
(n == null ? void 0 : n.id) === m ? "text-nvr-cyan" : "opacity-0"
|
|
329
|
+
)
|
|
330
|
+
}
|
|
331
|
+
),
|
|
332
|
+
/* @__PURE__ */ e("span", { className: "truncate", children: _ })
|
|
333
|
+
]
|
|
334
|
+
},
|
|
335
|
+
m
|
|
336
|
+
);
|
|
337
|
+
}),
|
|
338
|
+
N && o.length === 0 && /* @__PURE__ */ a("p", { className: "flex items-center gap-1.5 px-3 py-2 text-[12px] text-slate-400", children: [
|
|
339
|
+
/* @__PURE__ */ e(T, { className: "h-3 w-3 animate-spin" }),
|
|
340
|
+
" Searching…"
|
|
341
|
+
] }),
|
|
342
|
+
!N && o.length === 0 && !C && /* @__PURE__ */ e("p", { className: "px-3 py-2 text-[12px] text-slate-400", children: "No records match" })
|
|
343
|
+
] })
|
|
344
|
+
] })
|
|
345
|
+
] }),
|
|
346
|
+
n && /* @__PURE__ */ e(
|
|
347
|
+
"button",
|
|
348
|
+
{
|
|
349
|
+
type: "button",
|
|
350
|
+
"aria-label": "Clear the record",
|
|
351
|
+
"data-tip": "Clear the record",
|
|
352
|
+
onClick: () => r(null),
|
|
353
|
+
className: "flex h-6 w-6 items-center justify-center rounded text-slate-400 hover:bg-muted hover:text-slate-700 dark:hover:text-slate-200",
|
|
354
|
+
children: /* @__PURE__ */ e(L, { className: "h-3.5 w-3.5" })
|
|
355
|
+
}
|
|
356
|
+
)
|
|
357
|
+
] });
|
|
358
|
+
}
|
|
359
|
+
export {
|
|
360
|
+
me as OwnerRecordTrial,
|
|
361
|
+
V as OwnerTrialStrip
|
|
362
|
+
};
|