@nivaro/react 0.3.15 → 0.3.17
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 +127 -6
- package/dist/index.js +736 -734
- package/dist/shared/components/CollectionBrowserView.js +2344 -2309
- package/dist/shared/components/ItemEditForm.js +3773 -3604
- package/dist/shared/components/RecordGridEditor.js +319 -282
- package/dist/shared/components/RecordReadView.js +202 -200
- package/dist/shared/components/cbv/unknown-fields.js +18 -8
- package/dist/shared/components/chat/ChatAnalyticsView.js +2 -2
- package/dist/shared/components/import/DocumentAutofillButton.js +148 -142
- package/dist/shared/components/item-edit/CatalogPickerField.js +264 -276
- package/dist/shared/components/item-edit/FieldRenderer.js +136 -133
- package/dist/shared/components/item-edit/FieldRow.js +198 -184
- package/dist/shared/components/item-edit/HeaderTools.js +107 -99
- package/dist/shared/components/item-edit/InlineTableField.js +138 -136
- package/dist/shared/components/item-edit/RecordLiveSync.js +1 -0
- package/dist/shared/components/item-edit/RelationCombobox.js +30 -23
- package/dist/shared/components/item-edit/SummaryPanel.js +334 -294
- package/dist/shared/components/item-edit/column-length.js +12 -0
- package/dist/shared/components/panels/AccessDeniedPanel.js +47 -37
- package/dist/shared/components/panels/ItemLockBanner.js +307 -285
- package/dist/shared/components/panels/PipelinePanel.js +486 -465
- package/dist/shared/components/panels/RevisionsPanel.js +210 -204
- package/dist/shared/components/pipeline/PipelineEditorView.js +1672 -1568
- package/dist/shared/components/profile/DelegationCard.js +178 -121
- package/dist/shared/components/profile/PersonActivity.js +152 -139
- package/dist/shared/components/queue/QueueWorklist.js +668 -659
- package/dist/shared/components/queue/transition-note.js +90 -0
- package/dist/shared/components/support/SupportRequestDialog.js +100 -89
- package/dist/shared/components/support/TicketDetailSheet.js +104 -91
- package/dist/shared/lib/autofill-runs.js +33 -26
- package/dist/shared/lib/draft-store.js +40 -24
- package/dist/shared/lib/live-queries.js +10 -9
- package/dist/shared/lib/request-gate.js +140 -127
- package/dist/shared/lib/restore-skipped.js +10 -0
- package/package.json +1 -1
|
@@ -1,47 +1,47 @@
|
|
|
1
1
|
import { jsxs as l, Fragment as xe, jsx as a } from "react/jsx-runtime";
|
|
2
|
-
import { useQueryClient as
|
|
3
|
-
import { Loader2 as
|
|
4
|
-
import { useRef as
|
|
5
|
-
import { toast as
|
|
6
|
-
import { useApiFetchConfig as
|
|
7
|
-
import { askPickerNarrowing as
|
|
8
|
-
import { useAutofillRun as Ye, dismissAutofillRun as
|
|
9
|
-
import { cn as
|
|
10
|
-
import { RelationCombobox as
|
|
2
|
+
import { useQueryClient as Ue, useQuery as qe } from "@tanstack/react-query";
|
|
3
|
+
import { Loader2 as W, FileText as be, AlertTriangle as He, Wand2 as Le, ChevronDown as Me, ChevronRight as Ee, HelpCircle as Ke, CheckCircle2 as Qe } from "lucide-react";
|
|
4
|
+
import { useRef as I, useState as v, useEffect as U, useCallback as ge, useMemo as ye } from "react";
|
|
5
|
+
import { toast as q } from "sonner";
|
|
6
|
+
import { useApiFetchConfig as Oe, useOptionalNivaroClient as We } from "../../context.js";
|
|
7
|
+
import { askPickerNarrowing as Pe } from "../../lib/autofill-ask-filter.js";
|
|
8
|
+
import { useAutofillRun as Ye, dismissAutofillRun as P, setAutofillRunPresented as ke, isAutofillProposalId as Je, startAutofillRun as we } from "../../lib/autofill-runs.js";
|
|
9
|
+
import { cn as O } from "../../lib/utils.js";
|
|
10
|
+
import { RelationCombobox as Ge } from "../item-edit/RelationCombobox.js";
|
|
11
11
|
import { Button as Y } from "../ui/button.js";
|
|
12
|
-
import { Dialog as
|
|
13
|
-
import { SimpleSelect as
|
|
14
|
-
const
|
|
12
|
+
import { Dialog as Ve, DialogContent as ve, DialogHeader as Ne, DialogTitle as $e, DialogDescription as Ce, DialogFooter as Se } from "../ui/dialog.js";
|
|
13
|
+
import { SimpleSelect as _e } from "../ui/SimpleSelect.js";
|
|
14
|
+
const Ae = [
|
|
15
15
|
"Reading the document…",
|
|
16
16
|
"Finding the parties, dates and amounts…",
|
|
17
17
|
"Looking up vendors, people and categories…",
|
|
18
18
|
"Building the lines…",
|
|
19
19
|
"Checking the numbers…"
|
|
20
20
|
];
|
|
21
|
-
async function
|
|
22
|
-
var
|
|
21
|
+
async function Xe(r, d, b, g = {}) {
|
|
22
|
+
var S, R;
|
|
23
23
|
const p = Array.isArray(d) ? d : [d], w = new FormData();
|
|
24
|
-
w.append("collection", b), w.append("background", "1"), g.layoutId != null && w.append("layout_id", String(g.layoutId)), (
|
|
25
|
-
for (const
|
|
26
|
-
const
|
|
24
|
+
w.append("collection", b), w.append("background", "1"), g.layoutId != null && w.append("layout_id", String(g.layoutId)), (S = g.fileIds) != null && S.length && w.append("file_ids", g.fileIds.join(","));
|
|
25
|
+
for (const F of p) w.append("file", F, F.name);
|
|
26
|
+
const o = await fetch(`${r.apiBase}/ai/extract-record`, {
|
|
27
27
|
method: "POST",
|
|
28
28
|
headers: r.authHeaders,
|
|
29
29
|
credentials: r.credentials,
|
|
30
30
|
body: w
|
|
31
|
-
}), h = await
|
|
32
|
-
if (!
|
|
33
|
-
const i = String(((
|
|
31
|
+
}), h = await o.json().catch(() => ({}));
|
|
32
|
+
if (!o.ok) throw new Error((h == null ? void 0 : h.error) || `Document autofill failed (${o.status})`);
|
|
33
|
+
const i = String(((R = h == null ? void 0 : h.data) == null ? void 0 : R.proposal_id) ?? "");
|
|
34
34
|
if (!i) throw new Error("The server did not return a proposal id");
|
|
35
|
-
return g.notify && await fetch(`${r.apiBase}/ai/extract-record/${i}/notify`, {
|
|
35
|
+
return g.notify && await fetch(`${r.apiBase}/ai/extract-record/${encodeURIComponent(i)}/notify`, {
|
|
36
36
|
method: "POST",
|
|
37
37
|
headers: r.authHeaders,
|
|
38
38
|
credentials: r.credentials
|
|
39
39
|
}).catch(() => {
|
|
40
40
|
}), i;
|
|
41
41
|
}
|
|
42
|
-
function
|
|
43
|
-
const { apiBase: d, authHeaders: b, credentials: g } =
|
|
44
|
-
return
|
|
42
|
+
function Ze(r) {
|
|
43
|
+
const { apiBase: d, authHeaders: b, credentials: g } = Oe();
|
|
44
|
+
return qe({
|
|
45
45
|
queryKey: ["ai-extract-config", r],
|
|
46
46
|
enabled: !!r,
|
|
47
47
|
queryFn: async () => {
|
|
@@ -60,7 +60,7 @@ function J({ value: r }) {
|
|
|
60
60
|
"span",
|
|
61
61
|
{
|
|
62
62
|
"data-autofill-confidence": d,
|
|
63
|
-
className:
|
|
63
|
+
className: O(
|
|
64
64
|
"inline-flex h-5 shrink-0 items-center rounded px-1.5 text-[11px] font-medium tabular-nums",
|
|
65
65
|
b
|
|
66
66
|
),
|
|
@@ -79,18 +79,18 @@ function G(r) {
|
|
|
79
79
|
const d = String(r);
|
|
80
80
|
return d.length > 240 ? `${d.slice(0, 240)}…` : d;
|
|
81
81
|
}
|
|
82
|
-
function
|
|
82
|
+
function et({
|
|
83
83
|
ask: r,
|
|
84
84
|
value: d,
|
|
85
85
|
onChange: b,
|
|
86
86
|
draft: g,
|
|
87
87
|
labelOf: p
|
|
88
88
|
}) {
|
|
89
|
-
const w =
|
|
90
|
-
if (!
|
|
91
|
-
if (
|
|
89
|
+
const w = We(), o = r.input, h = "h-7 rounded-md border border-slate-200 bg-white px-2 text-[12px] dark:border-border dark:bg-background";
|
|
90
|
+
if (!o) return null;
|
|
91
|
+
if (o.type === "relation") {
|
|
92
92
|
if (!w) return null;
|
|
93
|
-
const i =
|
|
93
|
+
const i = Pe(o, g, p);
|
|
94
94
|
return /* @__PURE__ */ a(
|
|
95
95
|
"div",
|
|
96
96
|
{
|
|
@@ -98,9 +98,9 @@ function Ze({
|
|
|
98
98
|
"data-autofill-ask-input": "relation",
|
|
99
99
|
"data-autofill-ask-narrowed": i.narrowedBy.keys.join(",") || void 0,
|
|
100
100
|
children: /* @__PURE__ */ a(
|
|
101
|
-
|
|
101
|
+
Ge,
|
|
102
102
|
{
|
|
103
|
-
collection:
|
|
103
|
+
collection: o.collection,
|
|
104
104
|
value: d ?? null,
|
|
105
105
|
onChange: b,
|
|
106
106
|
extraFilter: i.extraFilter,
|
|
@@ -112,8 +112,8 @@ function Ze({
|
|
|
112
112
|
}
|
|
113
113
|
);
|
|
114
114
|
}
|
|
115
|
-
return
|
|
116
|
-
|
|
115
|
+
return o.type === "choices" ? /* @__PURE__ */ a(
|
|
116
|
+
_e,
|
|
117
117
|
{
|
|
118
118
|
className: `${h} w-auto`,
|
|
119
119
|
value: d == null ? "" : String(d),
|
|
@@ -121,11 +121,11 @@ function Ze({
|
|
|
121
121
|
triggerProps: { "data-autofill-ask-input": "choices" },
|
|
122
122
|
options: [
|
|
123
123
|
{ value: "", label: "Choose…" },
|
|
124
|
-
...
|
|
124
|
+
...o.choices.map((i) => ({ value: i.value, label: i.text }))
|
|
125
125
|
]
|
|
126
126
|
}
|
|
127
|
-
) :
|
|
128
|
-
|
|
127
|
+
) : o.type === "boolean" ? /* @__PURE__ */ a(
|
|
128
|
+
_e,
|
|
129
129
|
{
|
|
130
130
|
className: `${h} w-auto`,
|
|
131
131
|
value: d == null ? "" : d ? "true" : "false",
|
|
@@ -140,47 +140,53 @@ function Ze({
|
|
|
140
140
|
) : /* @__PURE__ */ a(
|
|
141
141
|
"input",
|
|
142
142
|
{
|
|
143
|
-
type:
|
|
144
|
-
className:
|
|
143
|
+
type: o.type === "number" ? "number" : o.type === "date" ? "date" : "text",
|
|
144
|
+
className: O(h, "w-48"),
|
|
145
145
|
value: d == null ? "" : String(d),
|
|
146
146
|
onChange: (i) => {
|
|
147
|
-
const
|
|
148
|
-
b(
|
|
147
|
+
const S = i.target.value;
|
|
148
|
+
b(S === "" ? null : o.type === "number" ? Number(S) : S);
|
|
149
149
|
},
|
|
150
150
|
placeholder: r.label,
|
|
151
|
-
"data-autofill-ask-input":
|
|
151
|
+
"data-autofill-ask-input": o.type
|
|
152
152
|
}
|
|
153
153
|
);
|
|
154
154
|
}
|
|
155
|
-
function
|
|
155
|
+
function pt({
|
|
156
156
|
collection: r,
|
|
157
157
|
onApply: d,
|
|
158
158
|
className: b,
|
|
159
159
|
layoutId: g,
|
|
160
160
|
initialProposalId: p,
|
|
161
161
|
label: w,
|
|
162
|
-
onProposalConsumed:
|
|
162
|
+
onProposalConsumed: o
|
|
163
163
|
}) {
|
|
164
164
|
var me, fe, pe, he;
|
|
165
|
-
const h =
|
|
166
|
-
|
|
165
|
+
const h = Oe(), { apiBase: i, authHeaders: S, credentials: R } = h, F = Ue(), V = I(null), X = I(null), [Re, Z] = v(null), [y, B] = v(null), x = Ye(y), [j, H] = v(!1), N = Re ?? ((x == null ? void 0 : x.status) === "reading" ? x.documentName : null), [Fe, ee] = v(0), [t, L] = v(null), [$, te] = v(/* @__PURE__ */ new Set()), [D, ae] = v(/* @__PURE__ */ new Set()), [A, ne] = v(/* @__PURE__ */ new Set()), [le, re] = v(/* @__PURE__ */ new Set()), [C, M] = v({}), [T, se] = v(!1), ie = I(null), { data: k } = Ze(r);
|
|
166
|
+
U(() => {
|
|
167
167
|
if (!N) return;
|
|
168
168
|
ee(0);
|
|
169
|
-
const e = setInterval(() => ee((n) => Math.min(n + 1,
|
|
169
|
+
const e = setInterval(() => ee((n) => Math.min(n + 1, Ae.length - 1)), 9e3);
|
|
170
170
|
return () => clearInterval(e);
|
|
171
171
|
}, [N]);
|
|
172
172
|
const de = ge((e) => {
|
|
173
|
-
|
|
174
|
-
}, []),
|
|
175
|
-
|
|
176
|
-
!x || j || (x.status === "ready" &&
|
|
177
|
-
}, [x, j, de,
|
|
173
|
+
L(e), te(new Set(e.fields.map((n) => n.field))), ae(new Set(e.children.map((n) => n.alias))), ne(new Set(e.m2m.map((n) => n.alias))), re(/* @__PURE__ */ new Set()), M({});
|
|
174
|
+
}, []), E = I(null);
|
|
175
|
+
U(() => {
|
|
176
|
+
!x || j || (x.status === "ready" && E.current !== x.id ? (E.current = x.id, de(x.proposal), F.invalidateQueries({ queryKey: ["nvr-ai-autofill-analytics"] })) : x.status === "failed" && (q.error(x.error ?? "Document autofill failed"), P(x.id), B(null)));
|
|
177
|
+
}, [x, j, de, F]), U(() => {
|
|
178
178
|
if (y)
|
|
179
179
|
return ke(y, !j), () => ke(y, !1);
|
|
180
|
-
}, [y, j]),
|
|
181
|
-
!p || ie.current === p
|
|
182
|
-
|
|
183
|
-
|
|
180
|
+
}, [y, j]), U(() => {
|
|
181
|
+
if (!(!p || ie.current === p)) {
|
|
182
|
+
if (ie.current = p, !Je(p)) {
|
|
183
|
+
o == null || o();
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
we(h, { id: p, collection: r }), B(p), H(!1), o == null || o();
|
|
187
|
+
}
|
|
188
|
+
}, [p, o]);
|
|
189
|
+
const _ = ye(
|
|
184
190
|
() => (t == null ? void 0 : t.children.reduce((e, n) => D.has(n.alias) ? e + n.lines.length : e, 0)) ?? 0,
|
|
185
191
|
[t, D]
|
|
186
192
|
), je = ye(() => {
|
|
@@ -188,30 +194,30 @@ function ft({
|
|
|
188
194
|
if (!t) return e;
|
|
189
195
|
for (const n of t.fields) $.has(n.field) && (e[n.field] = n.value);
|
|
190
196
|
for (const n of t.m2m)
|
|
191
|
-
|
|
197
|
+
A.has(n.alias) && n.items.length && (e[n.alias] = n.items.map((s) => s.id));
|
|
192
198
|
for (const [n, s] of Object.entries(C)) s != null && s !== "" && (e[n] = s);
|
|
193
199
|
return e;
|
|
194
|
-
}, [t, $,
|
|
200
|
+
}, [t, $, A, C]), De = ge(
|
|
195
201
|
(e) => {
|
|
196
|
-
var n, s,
|
|
197
|
-
return ((n = t == null ? void 0 : t.fields.find((
|
|
202
|
+
var n, s, c;
|
|
203
|
+
return ((n = t == null ? void 0 : t.fields.find((m) => m.field === e)) == null ? void 0 : n.label) ?? ((s = t == null ? void 0 : t.m2m.find((m) => m.alias === e)) == null ? void 0 : s.label) ?? ((c = t == null ? void 0 : t.asks.find((m) => m.field === e)) == null ? void 0 : c.label) ?? e.replace(/_/g, " ");
|
|
198
204
|
},
|
|
199
205
|
[t]
|
|
200
206
|
);
|
|
201
207
|
if (!(k != null && k.enabled) && !p) return null;
|
|
202
208
|
async function oe(e, n) {
|
|
203
|
-
var
|
|
209
|
+
var u;
|
|
204
210
|
if (!e.length) return;
|
|
205
|
-
const s = n && t ? ((
|
|
206
|
-
Z(
|
|
211
|
+
const s = n && t ? ((u = t.document.documents) == null ? void 0 : u.map((f) => f.file_id).filter((f) => !!f)) ?? (t.prefill.file_id ? [t.prefill.file_id] : []) : [], c = s.length + e.length, m = c === 1 ? e[0].name : `${c} documents`;
|
|
212
|
+
Z(m), H(!1);
|
|
207
213
|
try {
|
|
208
|
-
const
|
|
214
|
+
const f = await Xe(h, e, r, {
|
|
209
215
|
layoutId: g,
|
|
210
216
|
fileIds: s
|
|
211
217
|
});
|
|
212
|
-
n && y &&
|
|
213
|
-
} catch (
|
|
214
|
-
|
|
218
|
+
n && y && P(y), L(null), E.current = null, we(h, { id: f, collection: r, documentName: m, layoutId: g }), B(f);
|
|
219
|
+
} catch (f) {
|
|
220
|
+
q.error(f.message);
|
|
215
221
|
} finally {
|
|
216
222
|
Z(null);
|
|
217
223
|
}
|
|
@@ -226,57 +232,57 @@ function ft({
|
|
|
226
232
|
}
|
|
227
233
|
async function ze() {
|
|
228
234
|
if (y) {
|
|
229
|
-
|
|
235
|
+
H(!0);
|
|
230
236
|
try {
|
|
231
|
-
await fetch(`${i}/ai/extract-record/${y}/notify`, {
|
|
237
|
+
await fetch(`${i}/ai/extract-record/${encodeURIComponent(y)}/notify`, {
|
|
232
238
|
method: "POST",
|
|
233
|
-
headers:
|
|
234
|
-
credentials:
|
|
239
|
+
headers: S,
|
|
240
|
+
credentials: R
|
|
235
241
|
});
|
|
236
242
|
} catch {
|
|
237
|
-
|
|
243
|
+
q.error("Could not arrange the notification");
|
|
238
244
|
}
|
|
239
245
|
}
|
|
240
246
|
}
|
|
241
|
-
function
|
|
242
|
-
|
|
247
|
+
function K() {
|
|
248
|
+
L(null), y && P(y), B(null);
|
|
243
249
|
}
|
|
244
250
|
function z(e, n, s) {
|
|
245
|
-
const
|
|
246
|
-
|
|
251
|
+
const c = new Set(e);
|
|
252
|
+
c.has(n) ? c.delete(n) : c.add(n), s(c);
|
|
247
253
|
}
|
|
248
|
-
async function
|
|
254
|
+
async function Ie() {
|
|
249
255
|
if (t) {
|
|
250
256
|
se(!0);
|
|
251
257
|
try {
|
|
252
258
|
const e = {};
|
|
253
|
-
for (const
|
|
259
|
+
for (const u of t.fields) $.has(u.field) && (e[u.field] = u.value);
|
|
254
260
|
let n = 0;
|
|
255
|
-
for (const [
|
|
256
|
-
|
|
261
|
+
for (const [u, f] of Object.entries(C))
|
|
262
|
+
f == null || f === "" || (e[u] = f, n++);
|
|
257
263
|
const s = {};
|
|
258
|
-
for (const
|
|
259
|
-
D.has(
|
|
260
|
-
const
|
|
261
|
-
for (const
|
|
262
|
-
t.prefill.attach_alias && t.prefill.file_id && (
|
|
263
|
-
...
|
|
264
|
+
for (const u of t.children)
|
|
265
|
+
D.has(u.alias) && (s[u.alias] = u.lines.map((f) => ({ values: f.values })));
|
|
266
|
+
const c = {};
|
|
267
|
+
for (const u of t.m2m) A.has(u.alias) && (c[u.alias] = u.items.map((f) => f.id));
|
|
268
|
+
t.prefill.attach_alias && t.prefill.file_id && (c[t.prefill.attach_alias] = [
|
|
269
|
+
...c[t.prefill.attach_alias] ?? [],
|
|
264
270
|
t.prefill.file_id
|
|
265
|
-
]), fetch(`${i}/ai/extract-record/${t.id}/apply`, {
|
|
271
|
+
]), fetch(`${i}/ai/extract-record/${encodeURIComponent(String(t.id))}/apply`, {
|
|
266
272
|
method: "POST",
|
|
267
|
-
headers: { ...
|
|
268
|
-
credentials:
|
|
273
|
+
headers: { ...S, "Content-Type": "application/json" },
|
|
274
|
+
credentials: R,
|
|
269
275
|
body: JSON.stringify({
|
|
270
276
|
kept_fields: [...$],
|
|
271
|
-
kept_lines:
|
|
272
|
-
resolved_asks: Object.keys(C).filter((
|
|
277
|
+
kept_lines: _,
|
|
278
|
+
resolved_asks: Object.keys(C).filter((u) => C[u] != null && C[u] !== "")
|
|
273
279
|
})
|
|
274
280
|
}).catch(() => {
|
|
275
281
|
}), await d(
|
|
276
282
|
{
|
|
277
283
|
values: e,
|
|
278
284
|
lines_by_alias: s,
|
|
279
|
-
m2m:
|
|
285
|
+
m2m: c,
|
|
280
286
|
file_id: t.prefill.file_id,
|
|
281
287
|
summary: t.summary,
|
|
282
288
|
document_name: t.document.name,
|
|
@@ -284,16 +290,16 @@ function ft({
|
|
|
284
290
|
},
|
|
285
291
|
t
|
|
286
292
|
);
|
|
287
|
-
const
|
|
288
|
-
|
|
289
|
-
`Filled ${
|
|
290
|
-
),
|
|
293
|
+
const m = Object.keys(e).length;
|
|
294
|
+
q.success(
|
|
295
|
+
`Filled ${m} field${m === 1 ? "" : "s"}${_ ? ` and ${_} line${_ === 1 ? "" : "s"}` : ""}${n ? ` (${n} answered by you)` : ""} from ${t.document.name} — review, then Create`
|
|
296
|
+
), K();
|
|
291
297
|
} finally {
|
|
292
298
|
se(!1);
|
|
293
299
|
}
|
|
294
300
|
}
|
|
295
301
|
}
|
|
296
|
-
const ce = ((k == null ? void 0 : k.accept) ?? []).join(","),
|
|
302
|
+
const ce = ((k == null ? void 0 : k.accept) ?? []).join(","), Q = (t == null ? void 0 : t.asks) ?? [], ue = (e) => {
|
|
297
303
|
var n;
|
|
298
304
|
e.preventDefault(), (n = e.currentTarget) == null || n.focus();
|
|
299
305
|
};
|
|
@@ -333,22 +339,22 @@ function ft({
|
|
|
333
339
|
return (e = V.current) == null ? void 0 : e.click();
|
|
334
340
|
},
|
|
335
341
|
title: N ? void 0 : "Fill this record from one or more documents — a statement of work and its quote, a spreadsheet",
|
|
336
|
-
className:
|
|
342
|
+
className: O(
|
|
337
343
|
"inline-flex h-9 items-center gap-1.5 rounded-md border border-input bg-background px-3 text-sm font-medium shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground disabled:opacity-70",
|
|
338
344
|
b
|
|
339
345
|
),
|
|
340
346
|
children: [
|
|
341
|
-
N ? /* @__PURE__ */ a(
|
|
347
|
+
N ? /* @__PURE__ */ a(W, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ a(be, { className: "h-3.5 w-3.5" }),
|
|
342
348
|
N ? "Reading…" : w ?? "Fill from document"
|
|
343
349
|
]
|
|
344
350
|
}
|
|
345
351
|
),
|
|
346
352
|
/* @__PURE__ */ a(
|
|
347
|
-
|
|
353
|
+
Ve,
|
|
348
354
|
{
|
|
349
355
|
open: !j && (!!N || !!t),
|
|
350
356
|
onOpenChange: (e) => {
|
|
351
|
-
!e && !N && !T &&
|
|
357
|
+
!e && !N && !T && K();
|
|
352
358
|
},
|
|
353
359
|
children: N && !t ? /* @__PURE__ */ l(
|
|
354
360
|
ve,
|
|
@@ -359,16 +365,16 @@ function ft({
|
|
|
359
365
|
children: [
|
|
360
366
|
/* @__PURE__ */ l(Ne, { children: [
|
|
361
367
|
/* @__PURE__ */ l($e, { className: "flex items-center gap-2 text-[15px]", children: [
|
|
362
|
-
/* @__PURE__ */ a(
|
|
368
|
+
/* @__PURE__ */ a(W, { className: "h-4 w-4 animate-spin text-nvr-navy dark:text-nvr-cyan" }),
|
|
363
369
|
"Reading ",
|
|
364
370
|
N
|
|
365
371
|
] }),
|
|
366
372
|
/* @__PURE__ */ l(Ce, { children: [
|
|
367
|
-
|
|
373
|
+
Ae[Fe],
|
|
368
374
|
" Usually under a minute."
|
|
369
375
|
] })
|
|
370
376
|
] }),
|
|
371
|
-
y && /* @__PURE__ */ l(
|
|
377
|
+
y && /* @__PURE__ */ l(Se, { className: "sm:justify-start", children: [
|
|
372
378
|
/* @__PURE__ */ a(
|
|
373
379
|
Y,
|
|
374
380
|
{
|
|
@@ -409,7 +415,7 @@ function ft({
|
|
|
409
415
|
{
|
|
410
416
|
className: "flex items-start gap-2 rounded-md bg-amber-50 px-3 py-2 text-[12.5px] text-amber-900 dark:bg-amber-900/25 dark:text-amber-100",
|
|
411
417
|
children: [
|
|
412
|
-
/* @__PURE__ */ a(
|
|
418
|
+
/* @__PURE__ */ a(He, { className: "mt-0.5 h-3.5 w-3.5 shrink-0" }),
|
|
413
419
|
e
|
|
414
420
|
]
|
|
415
421
|
},
|
|
@@ -431,7 +437,7 @@ function ft({
|
|
|
431
437
|
{
|
|
432
438
|
"data-autofill-field": e.field,
|
|
433
439
|
"data-autofill-derived": ((s = e.derived) == null ? void 0 : s.by) ?? void 0,
|
|
434
|
-
className:
|
|
440
|
+
className: O(
|
|
435
441
|
"flex items-start gap-3 px-3 py-2",
|
|
436
442
|
!n && "opacity-55"
|
|
437
443
|
),
|
|
@@ -456,7 +462,7 @@ function ft({
|
|
|
456
462
|
className: "inline-flex h-5 items-center gap-1 rounded bg-sky-50 px-1.5 text-[10.5px] font-medium text-sky-800 dark:bg-sky-900/30 dark:text-sky-200",
|
|
457
463
|
title: e.source ?? void 0,
|
|
458
464
|
children: [
|
|
459
|
-
/* @__PURE__ */ a(
|
|
465
|
+
/* @__PURE__ */ a(Le, { className: "h-3 w-3" }),
|
|
460
466
|
e.derived.by === "field_rule" ? "rule" : "default"
|
|
461
467
|
]
|
|
462
468
|
}
|
|
@@ -479,14 +485,14 @@ function ft({
|
|
|
479
485
|
}) })
|
|
480
486
|
] }),
|
|
481
487
|
t.children.map((e) => {
|
|
482
|
-
const n = D.has(e.alias), s = le.has(e.alias),
|
|
483
|
-
e.lines.reduce((
|
|
484
|
-
for (const
|
|
485
|
-
return
|
|
488
|
+
const n = D.has(e.alias), s = le.has(e.alias), c = Object.keys(
|
|
489
|
+
e.lines.reduce((m, u) => {
|
|
490
|
+
for (const f of Object.keys(u.values)) m[f] = !0;
|
|
491
|
+
return m;
|
|
486
492
|
}, {})
|
|
487
493
|
).slice(0, 7);
|
|
488
494
|
return /* @__PURE__ */ l("section", { className: "mb-5", "data-autofill-child": e.alias, children: [
|
|
489
|
-
/* @__PURE__ */ l("div", { className:
|
|
495
|
+
/* @__PURE__ */ l("div", { className: O("flex items-center gap-3", !n && "opacity-55"), children: [
|
|
490
496
|
/* @__PURE__ */ a(
|
|
491
497
|
"input",
|
|
492
498
|
{
|
|
@@ -505,7 +511,7 @@ function ft({
|
|
|
505
511
|
onClick: () => z(le, e.alias, re),
|
|
506
512
|
"aria-expanded": s,
|
|
507
513
|
children: [
|
|
508
|
-
s ? /* @__PURE__ */ a(
|
|
514
|
+
s ? /* @__PURE__ */ a(Me, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ a(Ee, { className: "h-3.5 w-3.5" }),
|
|
509
515
|
e.label,
|
|
510
516
|
" · ",
|
|
511
517
|
e.lines.length,
|
|
@@ -517,22 +523,22 @@ function ft({
|
|
|
517
523
|
] }),
|
|
518
524
|
s && /* @__PURE__ */ a("div", { className: "mt-2 overflow-x-auto rounded-lg border border-slate-200 dark:border-border", children: /* @__PURE__ */ l("table", { className: "w-full text-[12px] tabular-nums", children: [
|
|
519
525
|
/* @__PURE__ */ a("thead", { className: "bg-slate-50 text-[10.5px] uppercase tracking-wide text-slate-500 dark:bg-muted", children: /* @__PURE__ */ l("tr", { children: [
|
|
520
|
-
|
|
526
|
+
c.map((m) => /* @__PURE__ */ a("th", { className: "px-2 py-1.5 text-left font-medium", children: m.replace(/_/g, " ") }, m)),
|
|
521
527
|
/* @__PURE__ */ a("th", { className: "px-2 py-1.5 text-right font-medium", children: "Conf." })
|
|
522
528
|
] }) }),
|
|
523
|
-
/* @__PURE__ */ a("tbody", { className: "divide-y divide-slate-100 dark:divide-border", children: e.lines.map((
|
|
529
|
+
/* @__PURE__ */ a("tbody", { className: "divide-y divide-slate-100 dark:divide-border", children: e.lines.map((m, u) => (
|
|
524
530
|
// biome-ignore lint/suspicious/noArrayIndexKey: proposal rows are static
|
|
525
|
-
/* @__PURE__ */ l("tr", { title:
|
|
526
|
-
|
|
531
|
+
/* @__PURE__ */ l("tr", { title: m.source ?? void 0, children: [
|
|
532
|
+
c.map((f) => /* @__PURE__ */ a(
|
|
527
533
|
"td",
|
|
528
534
|
{
|
|
529
535
|
className: "max-w-[260px] truncate px-2 py-1.5 text-slate-800 dark:text-slate-100",
|
|
530
|
-
children:
|
|
536
|
+
children: m.display[f] ?? G(m.values[f])
|
|
531
537
|
},
|
|
532
|
-
|
|
538
|
+
f
|
|
533
539
|
)),
|
|
534
|
-
/* @__PURE__ */ a("td", { className: "px-2 py-1.5 text-right", children: /* @__PURE__ */ a(J, { value:
|
|
535
|
-
] },
|
|
540
|
+
/* @__PURE__ */ a("td", { className: "px-2 py-1.5 text-right", children: /* @__PURE__ */ a(J, { value: m.confidence }) })
|
|
541
|
+
] }, u)
|
|
536
542
|
)) })
|
|
537
543
|
] }) })
|
|
538
544
|
] }, e.alias);
|
|
@@ -540,11 +546,11 @@ function ft({
|
|
|
540
546
|
t.m2m.length > 0 && /* @__PURE__ */ l("section", { className: "mb-5", "data-autofill-m2m": !0, children: [
|
|
541
547
|
/* @__PURE__ */ a("h3", { className: "mb-2 text-[11px] font-semibold uppercase tracking-wide text-slate-500", children: "Linked" }),
|
|
542
548
|
/* @__PURE__ */ a("ul", { className: "space-y-1.5", children: t.m2m.map((e) => {
|
|
543
|
-
const n =
|
|
549
|
+
const n = A.has(e.alias);
|
|
544
550
|
return /* @__PURE__ */ l(
|
|
545
551
|
"li",
|
|
546
552
|
{
|
|
547
|
-
className:
|
|
553
|
+
className: O(
|
|
548
554
|
"flex items-center gap-3 text-[12.5px]",
|
|
549
555
|
!n && "opacity-55"
|
|
550
556
|
),
|
|
@@ -555,7 +561,7 @@ function ft({
|
|
|
555
561
|
type: "checkbox",
|
|
556
562
|
className: "h-3.5 w-3.5 accent-nvr-cyan",
|
|
557
563
|
checked: n,
|
|
558
|
-
onChange: () => z(
|
|
564
|
+
onChange: () => z(A, e.alias, ne),
|
|
559
565
|
"aria-label": `Use ${e.label}`
|
|
560
566
|
}
|
|
561
567
|
),
|
|
@@ -574,13 +580,13 @@ function ft({
|
|
|
574
580
|
);
|
|
575
581
|
}) })
|
|
576
582
|
] }),
|
|
577
|
-
|
|
583
|
+
Q.length > 0 && /* @__PURE__ */ l("section", { "data-autofill-asks": !0, children: [
|
|
578
584
|
/* @__PURE__ */ l("h3", { className: "mb-2 flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-slate-500", children: [
|
|
579
|
-
/* @__PURE__ */ a(
|
|
585
|
+
/* @__PURE__ */ a(Ke, { className: "h-3.5 w-3.5" }),
|
|
580
586
|
" Still needs you · ",
|
|
581
|
-
|
|
587
|
+
Q.length
|
|
582
588
|
] }),
|
|
583
|
-
/* @__PURE__ */ a("ul", { className: "space-y-2", children:
|
|
589
|
+
/* @__PURE__ */ a("ul", { className: "space-y-2", children: Q.map((e) => {
|
|
584
590
|
const n = C[e.field] != null && C[e.field] !== "";
|
|
585
591
|
return /* @__PURE__ */ l(
|
|
586
592
|
"li",
|
|
@@ -596,13 +602,13 @@ function ft({
|
|
|
596
602
|
] }),
|
|
597
603
|
/* @__PURE__ */ l("div", { className: "mt-1.5 flex flex-wrap items-center gap-2", children: [
|
|
598
604
|
/* @__PURE__ */ a(
|
|
599
|
-
|
|
605
|
+
et,
|
|
600
606
|
{
|
|
601
607
|
ask: e,
|
|
602
608
|
value: C[e.field],
|
|
603
609
|
draft: je,
|
|
604
610
|
labelOf: De,
|
|
605
|
-
onChange: (s) =>
|
|
611
|
+
onChange: (s) => M((c) => ({ ...c, [e.field]: s }))
|
|
606
612
|
}
|
|
607
613
|
),
|
|
608
614
|
e.candidate && /* @__PURE__ */ l(
|
|
@@ -610,11 +616,11 @@ function ft({
|
|
|
610
616
|
{
|
|
611
617
|
type: "button",
|
|
612
618
|
"data-autofill-use-candidate": e.field,
|
|
613
|
-
onClick: () =>
|
|
614
|
-
var
|
|
619
|
+
onClick: () => M((s) => {
|
|
620
|
+
var c;
|
|
615
621
|
return {
|
|
616
622
|
...s,
|
|
617
|
-
[e.field]: (
|
|
623
|
+
[e.field]: (c = e.candidate) == null ? void 0 : c.value
|
|
618
624
|
};
|
|
619
625
|
}),
|
|
620
626
|
className: "inline-flex h-7 items-center gap-1.5 rounded-md border border-dashed border-slate-300 px-2 text-[12px] text-slate-700 hover:border-nvr-cyan hover:bg-nvr-cyan/5 dark:border-border dark:text-slate-200",
|
|
@@ -636,7 +642,7 @@ function ft({
|
|
|
636
642
|
] }),
|
|
637
643
|
t.fields.length === 0 && t.children.length === 0 && /* @__PURE__ */ a("p", { className: "text-[13px] text-slate-600 dark:text-slate-300", children: "Nothing in this document maps onto a field here. Try a document that names the record's parties, dates or amounts." })
|
|
638
644
|
] }),
|
|
639
|
-
/* @__PURE__ */ l(
|
|
645
|
+
/* @__PURE__ */ l(Se, { className: "items-center justify-between gap-3 border-t border-slate-200 px-5 py-3 dark:border-border sm:justify-between", children: [
|
|
640
646
|
/* @__PURE__ */ l("div", { className: "flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1", children: [
|
|
641
647
|
/* @__PURE__ */ l("span", { className: "text-[11.5px] text-slate-400", children: [
|
|
642
648
|
"Nothing is saved until you press Create. Model ",
|
|
@@ -684,7 +690,7 @@ function ft({
|
|
|
684
690
|
type: "button",
|
|
685
691
|
variant: "ghost",
|
|
686
692
|
size: "sm",
|
|
687
|
-
onClick:
|
|
693
|
+
onClick: K,
|
|
688
694
|
disabled: T,
|
|
689
695
|
children: "Cancel"
|
|
690
696
|
}
|
|
@@ -695,15 +701,15 @@ function ft({
|
|
|
695
701
|
type: "button",
|
|
696
702
|
size: "sm",
|
|
697
703
|
"data-autofill-apply": !0,
|
|
698
|
-
onClick:
|
|
699
|
-
disabled: T || $.size === 0 &&
|
|
704
|
+
onClick: Ie,
|
|
705
|
+
disabled: T || $.size === 0 && _ === 0 && A.size === 0 && !Object.values(C).some((e) => e != null && e !== ""),
|
|
700
706
|
children: [
|
|
701
|
-
T ? /* @__PURE__ */ a(
|
|
707
|
+
T ? /* @__PURE__ */ a(W, { className: "mr-1.5 h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ a(Qe, { className: "mr-1.5 h-3.5 w-3.5" }),
|
|
702
708
|
"Fill ",
|
|
703
709
|
$.size,
|
|
704
710
|
" field",
|
|
705
711
|
$.size === 1 ? "" : "s",
|
|
706
|
-
|
|
712
|
+
_ ? ` + ${_} line${_ === 1 ? "" : "s"}` : ""
|
|
707
713
|
]
|
|
708
714
|
}
|
|
709
715
|
)
|
|
@@ -717,7 +723,7 @@ function ft({
|
|
|
717
723
|
] });
|
|
718
724
|
}
|
|
719
725
|
export {
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
726
|
+
pt as DocumentAutofillButton,
|
|
727
|
+
Xe as startDocumentExtraction,
|
|
728
|
+
Ze as useDocumentAutofillConfig
|
|
723
729
|
};
|