@nivaro/react 0.3.145 → 0.3.147
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.
|
@@ -1,242 +1,260 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useQuery as
|
|
3
|
-
import { useState as f, useMemo as
|
|
4
|
-
import { useNivaroClient as
|
|
5
|
-
import { get as
|
|
6
|
-
import { useAfterIdle as
|
|
7
|
-
import { queryKeys as
|
|
8
|
-
import { hasRecordExtras as
|
|
9
|
-
import { formatRelative as
|
|
10
|
-
function
|
|
11
|
-
const
|
|
12
|
-
queryKey: ["record-integrity",
|
|
1
|
+
import { jsxs as s, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { useQuery as L, useQueryClient as ee, useMutation as M } from "@tanstack/react-query";
|
|
3
|
+
import { useState as f, useMemo as te, useEffect as re } from "react";
|
|
4
|
+
import { useNivaroClient as T } from "../../context.js";
|
|
5
|
+
import { get as X, post as K } from "../../lib/commands.js";
|
|
6
|
+
import { useAfterIdle as ne } from "../../lib/defer.js";
|
|
7
|
+
import { queryKeys as ae } from "../../lib/query-keys.js";
|
|
8
|
+
import { hasRecordExtras as ie } from "../../lib/system-collections.js";
|
|
9
|
+
import { formatRelative as oe, formatDateTime as de, cn as O, titleCase as se } from "../../lib/utils.js";
|
|
10
|
+
function le(r, t, n = !0) {
|
|
11
|
+
const l = T(), i = n && ie(r), { data: g } = L({
|
|
12
|
+
queryKey: ["record-integrity", r, t],
|
|
13
13
|
enabled: i,
|
|
14
|
-
queryFn: () =>
|
|
15
|
-
|
|
16
|
-
).then((
|
|
14
|
+
queryFn: () => l.request(
|
|
15
|
+
X(`/config-conformance/record/${r}/${encodeURIComponent(t)}`)
|
|
16
|
+
).then((o) => o.data).catch(() => ({ enabled: !1, findings: [] })),
|
|
17
17
|
staleTime: 5 * 6e4
|
|
18
|
-
}),
|
|
19
|
-
queryKey: ["record-integrity",
|
|
20
|
-
enabled: i &&
|
|
21
|
-
queryFn: () =>
|
|
22
|
-
|
|
23
|
-
).then((
|
|
18
|
+
}), p = ne(2e3), { data: m, isFetching: h } = L({
|
|
19
|
+
queryKey: ["record-integrity", r, t, "live"],
|
|
20
|
+
enabled: i && p,
|
|
21
|
+
queryFn: () => l.request(
|
|
22
|
+
K(`/config-conformance/record/${r}/${encodeURIComponent(t)}/check`, {})
|
|
23
|
+
).then((o) => o.data).catch(() => null),
|
|
24
24
|
staleTime: 6e4,
|
|
25
25
|
// Never spin the banner on a background refetch storm — one live check per
|
|
26
26
|
// mount / invalidation is the contract.
|
|
27
27
|
refetchOnWindowFocus: !1
|
|
28
28
|
});
|
|
29
|
-
return { data: m ??
|
|
29
|
+
return { data: m ?? g, checking: h };
|
|
30
30
|
}
|
|
31
|
-
const
|
|
32
|
-
function
|
|
33
|
-
var
|
|
34
|
-
const
|
|
35
|
-
for (const
|
|
36
|
-
const i =
|
|
37
|
-
i && typeof i.collection == "string" && i.item_id != null && i.item_id !== "" &&
|
|
31
|
+
const ce = "nvr:own-record-writes";
|
|
32
|
+
function Y(r) {
|
|
33
|
+
var n;
|
|
34
|
+
const t = [];
|
|
35
|
+
for (const l of r.writes ?? []) {
|
|
36
|
+
const i = l;
|
|
37
|
+
i && typeof i.collection == "string" && i.item_id != null && i.item_id !== "" && t.push({ collection: i.collection, id: String(i.item_id) });
|
|
38
38
|
}
|
|
39
|
-
return (
|
|
39
|
+
return (n = r.pick) != null && n.collection && r.pick.item_id && t.push({ collection: r.pick.collection, id: String(r.pick.item_id) }), t;
|
|
40
40
|
}
|
|
41
|
-
function
|
|
42
|
-
|
|
43
|
-
new CustomEvent(
|
|
41
|
+
function z(r) {
|
|
42
|
+
r.length === 0 || typeof window > "u" || window.dispatchEvent(
|
|
43
|
+
new CustomEvent(ce, { detail: { writes: r } })
|
|
44
44
|
);
|
|
45
45
|
}
|
|
46
|
-
function
|
|
47
|
-
var
|
|
48
|
-
const
|
|
49
|
-
return ((
|
|
46
|
+
function ue(r, t) {
|
|
47
|
+
var l;
|
|
48
|
+
const n = t == null ? void 0 : t.find((i) => i.field === r);
|
|
49
|
+
return ((l = n == null ? void 0 : n.label) == null ? void 0 : l.trim()) || se(r);
|
|
50
50
|
}
|
|
51
|
-
function
|
|
52
|
-
const
|
|
53
|
-
for (const
|
|
54
|
-
const
|
|
55
|
-
|
|
51
|
+
function we(r) {
|
|
52
|
+
const t = /* @__PURE__ */ new Map();
|
|
53
|
+
for (const n of r ?? []) {
|
|
54
|
+
const l = t.get(n.field) ?? [];
|
|
55
|
+
l.push(n), t.set(n.field, l);
|
|
56
56
|
}
|
|
57
|
-
return
|
|
57
|
+
return t;
|
|
58
58
|
}
|
|
59
|
-
const
|
|
59
|
+
const G = {
|
|
60
60
|
high: { dot: "bg-emerald-500", text: "Confident" },
|
|
61
61
|
medium: { dot: "bg-amber-500", text: "Likely" },
|
|
62
62
|
low: { dot: "bg-slate-400", text: "Manual" }
|
|
63
63
|
};
|
|
64
|
-
function
|
|
65
|
-
collection:
|
|
66
|
-
itemId:
|
|
67
|
-
onJumpToField:
|
|
64
|
+
function Ce({
|
|
65
|
+
collection: r,
|
|
66
|
+
itemId: t,
|
|
67
|
+
onJumpToField: n
|
|
68
68
|
}) {
|
|
69
|
-
var
|
|
70
|
-
const
|
|
71
|
-
queryKey:
|
|
72
|
-
queryFn: () =>
|
|
73
|
-
enabled: !!((
|
|
69
|
+
var N;
|
|
70
|
+
const l = T(), i = ee(), [g, p] = f(!1), [m, h] = f(null), { data: o, checking: E } = le(r, t), { data: P } = L({
|
|
71
|
+
queryKey: ae.fieldConfig(r, null),
|
|
72
|
+
queryFn: () => l.request(X(`/field-config/${r}`)).then((d) => d.data ?? []),
|
|
73
|
+
enabled: !!((N = o == null ? void 0 : o.findings) != null && N.length),
|
|
74
74
|
staleTime: 6e4
|
|
75
|
-
}),
|
|
76
|
-
i.invalidateQueries({ queryKey: ["record-integrity", t, r] }), i.invalidateQueries({ queryKey: ["item",
|
|
75
|
+
}), v = () => {
|
|
76
|
+
i.invalidateQueries({ queryKey: ["record-integrity", r, t] }), i.invalidateQueries({ queryKey: ["integrity-proposals", r, t] }), i.invalidateQueries({ queryKey: ["item", r, t] }), i.invalidateQueries({ queryKey: ["rrv-record", r, t] }), i.invalidateQueries({ queryKey: ["o2m-rows"] }), i.invalidateQueries({ queryKey: ["revisions"] });
|
|
77
77
|
};
|
|
78
|
-
if (!(
|
|
79
|
-
const
|
|
80
|
-
return /* @__PURE__ */
|
|
78
|
+
if (!(o != null && o.enabled) || o.findings.length === 0) return null;
|
|
79
|
+
const R = o.findings.length;
|
|
80
|
+
return /* @__PURE__ */ s(
|
|
81
81
|
"div",
|
|
82
82
|
{
|
|
83
83
|
"data-record-integrity": !0,
|
|
84
84
|
className: "nvr-expand-in rounded-lg border border-amber-200 bg-amber-50 px-4 py-2.5 dark:border-amber-500/30 dark:bg-amber-400/10",
|
|
85
85
|
children: [
|
|
86
|
-
/* @__PURE__ */
|
|
87
|
-
/* @__PURE__ */
|
|
88
|
-
|
|
86
|
+
/* @__PURE__ */ s("div", { className: "flex items-center gap-2", children: [
|
|
87
|
+
/* @__PURE__ */ s("span", { className: "text-[12.5px] font-medium text-amber-800 dark:text-amber-300", children: [
|
|
88
|
+
R,
|
|
89
89
|
" data integrity issue",
|
|
90
|
-
|
|
90
|
+
R === 1 ? "" : "s",
|
|
91
91
|
" on this record"
|
|
92
92
|
] }),
|
|
93
|
-
|
|
93
|
+
o.live ? /* @__PURE__ */ a(
|
|
94
94
|
"span",
|
|
95
95
|
{
|
|
96
96
|
className: "text-[11px] text-amber-600/80 dark:text-amber-400/70",
|
|
97
97
|
"data-integrity-checked": "live",
|
|
98
98
|
children: "checked just now"
|
|
99
99
|
}
|
|
100
|
-
) : E ? /* @__PURE__ */
|
|
100
|
+
) : E ? /* @__PURE__ */ a(
|
|
101
101
|
"span",
|
|
102
102
|
{
|
|
103
103
|
className: "text-[11px] text-amber-600/80 dark:text-amber-400/70",
|
|
104
104
|
"data-integrity-checked": "checking",
|
|
105
105
|
children: "checking…"
|
|
106
106
|
}
|
|
107
|
-
) :
|
|
107
|
+
) : o.checked_at ? /* @__PURE__ */ s(
|
|
108
108
|
"span",
|
|
109
109
|
{
|
|
110
110
|
className: "text-[11px] text-amber-600/80 dark:text-amber-400/70",
|
|
111
111
|
"data-integrity-checked": "stored",
|
|
112
|
-
title:
|
|
112
|
+
title: de(o.checked_at),
|
|
113
113
|
children: [
|
|
114
114
|
"checked ",
|
|
115
|
-
|
|
115
|
+
oe(o.checked_at)
|
|
116
116
|
]
|
|
117
117
|
}
|
|
118
118
|
) : null,
|
|
119
|
-
/* @__PURE__ */
|
|
119
|
+
/* @__PURE__ */ a(
|
|
120
120
|
"button",
|
|
121
121
|
{
|
|
122
122
|
type: "button",
|
|
123
|
-
onClick: () =>
|
|
123
|
+
onClick: () => p((d) => !d),
|
|
124
124
|
className: "ml-auto text-[11.5px] font-medium text-amber-700 underline decoration-dotted underline-offset-2 dark:text-amber-300",
|
|
125
|
-
children:
|
|
125
|
+
children: g ? "Hide" : "View"
|
|
126
126
|
}
|
|
127
127
|
)
|
|
128
128
|
] }),
|
|
129
|
-
|
|
130
|
-
/* @__PURE__ */
|
|
131
|
-
/* @__PURE__ */
|
|
129
|
+
g && /* @__PURE__ */ a("div", { className: "mt-1.5 space-y-1", children: o.findings.map((d) => /* @__PURE__ */ s("div", { children: [
|
|
130
|
+
/* @__PURE__ */ s("div", { className: "flex items-baseline gap-2 text-[12px]", children: [
|
|
131
|
+
/* @__PURE__ */ a(
|
|
132
132
|
"button",
|
|
133
133
|
{
|
|
134
134
|
type: "button",
|
|
135
|
-
onClick: () =>
|
|
136
|
-
"data-integrity-field":
|
|
135
|
+
onClick: () => n == null ? void 0 : n(d.field),
|
|
136
|
+
"data-integrity-field": d.field,
|
|
137
137
|
className: "shrink-0 text-[11.5px] font-medium text-amber-700 underline decoration-dotted underline-offset-2 dark:text-amber-300",
|
|
138
|
-
children:
|
|
138
|
+
children: ue(d.field, P)
|
|
139
139
|
}
|
|
140
140
|
),
|
|
141
|
-
/* @__PURE__ */
|
|
142
|
-
|
|
141
|
+
/* @__PURE__ */ a("span", { className: "min-w-0 flex-1 text-amber-800 dark:text-amber-200/90", children: d.message }),
|
|
142
|
+
d.fixable && /* @__PURE__ */ a(
|
|
143
143
|
"button",
|
|
144
144
|
{
|
|
145
145
|
type: "button",
|
|
146
|
-
onClick: () =>
|
|
147
|
-
className:
|
|
146
|
+
onClick: () => h((w) => w === k(d) ? null : k(d)),
|
|
147
|
+
className: O(
|
|
148
148
|
"shrink-0 rounded px-2 py-0.5 text-[10.5px] font-semibold transition-colors",
|
|
149
|
-
m ===
|
|
149
|
+
m === k(d) ? "bg-amber-200 text-amber-900 dark:bg-amber-400/30 dark:text-amber-100" : "bg-amber-600 text-white hover:bg-amber-700"
|
|
150
150
|
),
|
|
151
|
-
children: m ===
|
|
151
|
+
children: m === k(d) ? "Close" : "Fix…"
|
|
152
152
|
}
|
|
153
153
|
)
|
|
154
154
|
] }),
|
|
155
|
-
m ===
|
|
156
|
-
|
|
155
|
+
m === k(d) && /* @__PURE__ */ a(
|
|
156
|
+
me,
|
|
157
157
|
{
|
|
158
|
-
collection:
|
|
159
|
-
itemId:
|
|
160
|
-
finding:
|
|
161
|
-
onApplied:
|
|
162
|
-
onClose: () =>
|
|
163
|
-
}
|
|
158
|
+
collection: r,
|
|
159
|
+
itemId: t,
|
|
160
|
+
finding: d,
|
|
161
|
+
onApplied: v,
|
|
162
|
+
onClose: () => h(null)
|
|
163
|
+
},
|
|
164
|
+
k(d)
|
|
164
165
|
)
|
|
165
|
-
] },
|
|
166
|
+
] }, k(d))) })
|
|
166
167
|
]
|
|
167
168
|
}
|
|
168
169
|
);
|
|
169
170
|
}
|
|
170
|
-
function
|
|
171
|
-
collection:
|
|
172
|
-
itemId:
|
|
173
|
-
finding:
|
|
174
|
-
onApplied:
|
|
171
|
+
function me({
|
|
172
|
+
collection: r,
|
|
173
|
+
itemId: t,
|
|
174
|
+
finding: n,
|
|
175
|
+
onApplied: l,
|
|
175
176
|
onClose: i
|
|
176
177
|
}) {
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
|
|
178
|
+
const g = T(), p = `/config-conformance/record/${r}/${encodeURIComponent(t)}`, m = { field: n.field, rule: n.rule, message: n.message }, { data: h, isLoading: o, error: E, refetch: P } = L({
|
|
179
|
+
// The message is part of the finding: one field and rule can carry several findings
|
|
180
|
+
// ("Line 1: …", "Line 2: …"), each with its own proposals.
|
|
181
|
+
queryKey: [
|
|
182
|
+
"integrity-proposals",
|
|
183
|
+
r,
|
|
184
|
+
t,
|
|
185
|
+
n.field,
|
|
186
|
+
n.rule,
|
|
187
|
+
n.message
|
|
188
|
+
],
|
|
189
|
+
queryFn: () => g.request(K(`${p}/proposals`, m)).then((e) => e.data.proposals),
|
|
180
190
|
staleTime: 6e4
|
|
181
|
-
}), [
|
|
182
|
-
|
|
183
|
-
if (!
|
|
184
|
-
|
|
185
|
-
const e = setInterval(() =>
|
|
191
|
+
}), [v, R] = f([]), [N, d] = f({}), [w, Z] = f(""), [b, j] = f(null), [D, I] = f(0), [B, y] = f(null), [V, J] = f(null), [_, A] = f(null), H = te(() => [...h ?? [], ...v], [h, v]);
|
|
192
|
+
re(() => {
|
|
193
|
+
if (!b || b.undo.length === 0) return;
|
|
194
|
+
I(30);
|
|
195
|
+
const e = setInterval(() => I((u) => u <= 1 ? 0 : u - 1), 1e3);
|
|
186
196
|
return () => clearInterval(e);
|
|
187
|
-
}, [
|
|
188
|
-
const
|
|
189
|
-
mutationFn: (e) =>
|
|
190
|
-
|
|
197
|
+
}, [b]);
|
|
198
|
+
const F = M({
|
|
199
|
+
mutationFn: (e) => g.request(
|
|
200
|
+
K(`${p}/fix`, {
|
|
191
201
|
...m,
|
|
192
202
|
proposal_id: e.id,
|
|
193
|
-
choice: e.kind === "pick" ?
|
|
203
|
+
choice: e.kind === "pick" ? N[e.id] : void 0
|
|
194
204
|
})
|
|
195
205
|
),
|
|
196
|
-
onSuccess: (e,
|
|
197
|
-
var
|
|
198
|
-
|
|
199
|
-
const x = e.data,
|
|
200
|
-
|
|
201
|
-
text:
|
|
206
|
+
onSuccess: (e, u) => {
|
|
207
|
+
var q, $, c;
|
|
208
|
+
y(null), z(Y(u)), J(u);
|
|
209
|
+
const x = e.data, C = ((q = x.failed) == null ? void 0 : q.length) ?? 0;
|
|
210
|
+
j({
|
|
211
|
+
text: u.kind === "notify" ? `Sent to ${(($ = u.notify) == null ? void 0 : $.name) ?? "the owner"} as a task.` : `${x.applied} write${x.applied === 1 ? "" : "s"} applied${C ? ` — ${C} failed: ${((c = x.failed[0]) == null ? void 0 : c.error) ?? ""}` : ""}.`,
|
|
202
212
|
undo: x.undo ?? []
|
|
203
|
-
}),
|
|
213
|
+
}), l();
|
|
204
214
|
},
|
|
205
|
-
onError: (e) =>
|
|
206
|
-
|
|
207
|
-
|
|
215
|
+
onError: (e) => {
|
|
216
|
+
if (xe(e) === 409) {
|
|
217
|
+
A(null), y(
|
|
218
|
+
"The record changed, so these suggestions were refreshed. Check them and apply again."
|
|
219
|
+
), P();
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
y(S(e));
|
|
223
|
+
}
|
|
224
|
+
}), Q = M({
|
|
225
|
+
mutationFn: (e) => g.request(K(`${p}/fix`, { ...m, undo: e })),
|
|
208
226
|
onSuccess: () => {
|
|
209
|
-
|
|
227
|
+
V && z(Y(V)), j({ text: "Undone.", undo: [] }), l();
|
|
210
228
|
},
|
|
211
|
-
onError: (e) =>
|
|
212
|
-
}),
|
|
213
|
-
mutationFn: () =>
|
|
229
|
+
onError: (e) => y(S(e))
|
|
230
|
+
}), U = M({
|
|
231
|
+
mutationFn: () => g.request(K(`${p}/proposals/ai`, m)).then((e) => e.data.proposal),
|
|
214
232
|
onSuccess: (e) => {
|
|
215
|
-
|
|
233
|
+
y(null), R((u) => u.some((x) => x.id === e.id) ? u : [...u, e]);
|
|
216
234
|
},
|
|
217
|
-
onError: (e) =>
|
|
235
|
+
onError: (e) => y(S(e))
|
|
218
236
|
});
|
|
219
|
-
return /* @__PURE__ */
|
|
237
|
+
return /* @__PURE__ */ s(
|
|
220
238
|
"div",
|
|
221
239
|
{
|
|
222
240
|
"data-integrity-proposals": !0,
|
|
223
241
|
className: "mt-1.5 rounded-md border border-amber-200/80 bg-white/70 px-3 py-2 dark:border-amber-500/20 dark:bg-black/20",
|
|
224
242
|
children: [
|
|
225
|
-
|
|
226
|
-
E && /* @__PURE__ */
|
|
227
|
-
|
|
228
|
-
/* @__PURE__ */
|
|
229
|
-
|
|
243
|
+
o && /* @__PURE__ */ a("p", { className: "text-[11.5px] text-slate-500 dark:text-muted-foreground", children: "Working out what would fix this…" }),
|
|
244
|
+
E && /* @__PURE__ */ a("p", { className: "text-[11.5px] text-red-600 dark:text-red-400", children: S(E) }),
|
|
245
|
+
b ? /* @__PURE__ */ s("div", { className: "flex flex-wrap items-center gap-2 text-[11.5px]", children: [
|
|
246
|
+
/* @__PURE__ */ a("span", { className: "font-medium text-emerald-700 dark:text-emerald-400", children: b.text }),
|
|
247
|
+
b.undo.length > 0 && D > 0 && /* @__PURE__ */ a(
|
|
230
248
|
"button",
|
|
231
249
|
{
|
|
232
250
|
type: "button",
|
|
233
|
-
disabled:
|
|
234
|
-
onClick: () =>
|
|
251
|
+
disabled: Q.isPending,
|
|
252
|
+
onClick: () => Q.mutate(b.undo),
|
|
235
253
|
className: "rounded border border-slate-300 px-2 py-0.5 text-[11px] font-medium text-slate-700 hover:bg-slate-50 disabled:opacity-50 dark:border-border dark:text-foreground dark:hover:bg-muted",
|
|
236
|
-
children:
|
|
254
|
+
children: Q.isPending ? "Undoing…" : `Undo (${D}s)`
|
|
237
255
|
}
|
|
238
256
|
),
|
|
239
|
-
/* @__PURE__ */
|
|
257
|
+
/* @__PURE__ */ a(
|
|
240
258
|
"button",
|
|
241
259
|
{
|
|
242
260
|
type: "button",
|
|
@@ -245,33 +263,33 @@ function ce({
|
|
|
245
263
|
children: "Done"
|
|
246
264
|
}
|
|
247
265
|
)
|
|
248
|
-
] }) : !
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
var
|
|
252
|
-
const
|
|
253
|
-
(
|
|
266
|
+
] }) : !o && /* @__PURE__ */ s("div", { className: "space-y-1.5", children: [
|
|
267
|
+
H.length === 0 && /* @__PURE__ */ a("p", { className: "text-[11.5px] text-slate-500 dark:text-muted-foreground", children: "Nothing on this record can derive a value — fix it by hand on the form." }),
|
|
268
|
+
H.map((e) => {
|
|
269
|
+
var q, $;
|
|
270
|
+
const u = G[e.confidence] ?? G.low, x = N[e.id], C = (e.choices ?? []).filter(
|
|
271
|
+
(c) => !w || c.label.toLowerCase().includes(w.toLowerCase())
|
|
254
272
|
);
|
|
255
|
-
return /* @__PURE__ */
|
|
273
|
+
return /* @__PURE__ */ a(
|
|
256
274
|
"div",
|
|
257
275
|
{
|
|
258
276
|
className: "rounded border border-slate-200/80 bg-white px-2.5 py-1.5 dark:border-border dark:bg-card",
|
|
259
|
-
children: /* @__PURE__ */
|
|
260
|
-
/* @__PURE__ */
|
|
277
|
+
children: /* @__PURE__ */ s("div", { className: "flex items-start gap-2", children: [
|
|
278
|
+
/* @__PURE__ */ a(
|
|
261
279
|
"span",
|
|
262
280
|
{
|
|
263
|
-
className:
|
|
264
|
-
title:
|
|
265
|
-
"data-tip":
|
|
281
|
+
className: O("mt-1.5 h-2 w-2 shrink-0 rounded-full", u.dot),
|
|
282
|
+
title: u.text,
|
|
283
|
+
"data-tip": u.text
|
|
266
284
|
}
|
|
267
285
|
),
|
|
268
|
-
/* @__PURE__ */
|
|
269
|
-
/* @__PURE__ */
|
|
286
|
+
/* @__PURE__ */ s("div", { className: "min-w-0 flex-1", children: [
|
|
287
|
+
/* @__PURE__ */ s("p", { className: "text-[12px] font-medium text-slate-800 dark:text-foreground", children: [
|
|
270
288
|
e.label,
|
|
271
|
-
/* @__PURE__ */
|
|
289
|
+
/* @__PURE__ */ a("span", { className: "ml-1.5 text-[10px] font-normal uppercase tracking-wide text-slate-400", children: e.kind === "ai" ? "AI" : u.text })
|
|
272
290
|
] }),
|
|
273
|
-
/* @__PURE__ */
|
|
274
|
-
e.confirm && _ === e.id && /* @__PURE__ */
|
|
291
|
+
/* @__PURE__ */ a("p", { className: "text-[11px] leading-snug text-slate-500 dark:text-muted-foreground", children: e.basis }),
|
|
292
|
+
e.confirm && _ === e.id && /* @__PURE__ */ s(
|
|
275
293
|
"p",
|
|
276
294
|
{
|
|
277
295
|
role: "alert",
|
|
@@ -280,11 +298,11 @@ function ce({
|
|
|
280
298
|
children: [
|
|
281
299
|
e.confirm,
|
|
282
300
|
" ",
|
|
283
|
-
/* @__PURE__ */
|
|
301
|
+
/* @__PURE__ */ a(
|
|
284
302
|
"button",
|
|
285
303
|
{
|
|
286
304
|
type: "button",
|
|
287
|
-
onClick: () =>
|
|
305
|
+
onClick: () => A(null),
|
|
288
306
|
className: "font-normal text-slate-600 underline underline-offset-2 hover:text-slate-900 dark:text-muted-foreground dark:hover:text-foreground",
|
|
289
307
|
children: "Keep it"
|
|
290
308
|
}
|
|
@@ -292,74 +310,74 @@ function ce({
|
|
|
292
310
|
]
|
|
293
311
|
}
|
|
294
312
|
),
|
|
295
|
-
e.preview.length > 0 && /* @__PURE__ */
|
|
296
|
-
e.preview.slice(0, 8).map((
|
|
313
|
+
e.preview.length > 0 && /* @__PURE__ */ s("div", { className: "mt-1 flex flex-wrap gap-1", children: [
|
|
314
|
+
e.preview.slice(0, 8).map((c, W) => /* @__PURE__ */ s(
|
|
297
315
|
"span",
|
|
298
316
|
{
|
|
299
317
|
className: "rounded bg-slate-100 px-1.5 py-0.5 text-[10.5px] text-slate-700 dark:bg-muted dark:text-foreground",
|
|
300
318
|
children: [
|
|
301
|
-
|
|
319
|
+
c.label,
|
|
302
320
|
": ",
|
|
303
|
-
/* @__PURE__ */
|
|
321
|
+
/* @__PURE__ */ a("span", { className: "line-through opacity-60", children: c.from }),
|
|
304
322
|
" ",
|
|
305
323
|
"→ ",
|
|
306
|
-
/* @__PURE__ */
|
|
324
|
+
/* @__PURE__ */ a("span", { className: "font-medium", children: c.to })
|
|
307
325
|
]
|
|
308
326
|
},
|
|
309
|
-
`${
|
|
327
|
+
`${c.item_id}|${c.field}|${W}`
|
|
310
328
|
)),
|
|
311
|
-
e.preview.length > 8 && /* @__PURE__ */
|
|
329
|
+
e.preview.length > 8 && /* @__PURE__ */ s("span", { className: "text-[10.5px] text-slate-400", children: [
|
|
312
330
|
"+",
|
|
313
331
|
e.preview.length - 8,
|
|
314
332
|
" more"
|
|
315
333
|
] })
|
|
316
334
|
] }),
|
|
317
|
-
e.kind === "pick" && /* @__PURE__ */
|
|
318
|
-
(((
|
|
335
|
+
e.kind === "pick" && /* @__PURE__ */ s("div", { className: "mt-1.5", children: [
|
|
336
|
+
(((q = e.choices) == null ? void 0 : q.length) ?? 0) > 8 && /* @__PURE__ */ a(
|
|
319
337
|
"input",
|
|
320
338
|
{
|
|
321
|
-
value:
|
|
322
|
-
onChange: (
|
|
339
|
+
value: w,
|
|
340
|
+
onChange: (c) => Z(c.target.value),
|
|
323
341
|
placeholder: "Filter options…",
|
|
324
342
|
className: "mb-1 h-6 w-full rounded border border-slate-200 bg-white px-2 text-[11px] dark:border-border dark:bg-background"
|
|
325
343
|
}
|
|
326
344
|
),
|
|
327
|
-
/* @__PURE__ */
|
|
328
|
-
|
|
345
|
+
/* @__PURE__ */ s("div", { className: "flex max-h-36 flex-wrap gap-1 overflow-y-auto", children: [
|
|
346
|
+
C.map((c) => /* @__PURE__ */ a(
|
|
329
347
|
"button",
|
|
330
348
|
{
|
|
331
349
|
type: "button",
|
|
332
|
-
onClick: () =>
|
|
333
|
-
className:
|
|
350
|
+
onClick: () => d((W) => ({ ...W, [e.id]: c.id })),
|
|
351
|
+
className: O(
|
|
334
352
|
"rounded border px-1.5 py-0.5 text-[11px] transition-colors",
|
|
335
|
-
x ===
|
|
353
|
+
x === c.id ? "border-nvr-cyan bg-nvr-cyan/10 text-slate-900 dark:text-foreground" : "border-slate-200 text-slate-700 hover:bg-muted dark:border-border dark:text-foreground"
|
|
336
354
|
),
|
|
337
|
-
children:
|
|
355
|
+
children: c.label
|
|
338
356
|
},
|
|
339
|
-
|
|
357
|
+
c.id
|
|
340
358
|
)),
|
|
341
|
-
|
|
359
|
+
C.length === 0 && /* @__PURE__ */ a("span", { className: "text-[11px] text-slate-400", children: "No options match." })
|
|
342
360
|
] })
|
|
343
361
|
] })
|
|
344
362
|
] }),
|
|
345
|
-
/* @__PURE__ */
|
|
363
|
+
/* @__PURE__ */ a(
|
|
346
364
|
"button",
|
|
347
365
|
{
|
|
348
366
|
type: "button",
|
|
349
|
-
disabled:
|
|
367
|
+
disabled: F.isPending || e.kind === "pick" && !x,
|
|
350
368
|
"data-integrity-apply": e.id,
|
|
351
369
|
onClick: () => {
|
|
352
370
|
if (e.confirm && _ !== e.id) {
|
|
353
|
-
|
|
371
|
+
A(e.id);
|
|
354
372
|
return;
|
|
355
373
|
}
|
|
356
|
-
|
|
374
|
+
A(null), F.mutate(e);
|
|
357
375
|
},
|
|
358
|
-
className:
|
|
376
|
+
className: O(
|
|
359
377
|
"shrink-0 rounded px-2 py-0.5 text-[10.5px] font-semibold text-white transition-colors disabled:opacity-50",
|
|
360
378
|
e.confirm && _ === e.id ? "bg-red-600 hover:bg-red-700" : e.kind === "notify" ? "bg-slate-600 hover:bg-slate-700" : "bg-nvr-cyan hover:bg-nvr-cyan-dark"
|
|
361
379
|
),
|
|
362
|
-
children:
|
|
380
|
+
children: F.isPending && (($ = F.variables) == null ? void 0 : $.id) === e.id ? "Applying…" : e.confirm && _ === e.id ? "Yes, remove" : e.kind === "notify" ? "Send" : e.confirm ? "Remove" : "Apply"
|
|
363
381
|
}
|
|
364
382
|
)
|
|
365
383
|
] })
|
|
@@ -367,18 +385,18 @@ function ce({
|
|
|
367
385
|
e.id
|
|
368
386
|
);
|
|
369
387
|
}),
|
|
370
|
-
/* @__PURE__ */
|
|
371
|
-
!
|
|
388
|
+
/* @__PURE__ */ s("div", { className: "flex items-center gap-2 pt-0.5", children: [
|
|
389
|
+
!v.some((e) => e.kind === "ai") && /* @__PURE__ */ a(
|
|
372
390
|
"button",
|
|
373
391
|
{
|
|
374
392
|
type: "button",
|
|
375
|
-
disabled:
|
|
376
|
-
onClick: () =>
|
|
393
|
+
disabled: U.isPending,
|
|
394
|
+
onClick: () => U.mutate(),
|
|
377
395
|
className: "text-[11px] font-medium text-slate-600 underline decoration-dotted underline-offset-2 hover:text-slate-900 disabled:opacity-50 dark:text-muted-foreground dark:hover:text-foreground",
|
|
378
|
-
children:
|
|
396
|
+
children: U.isPending ? "Asking AI…" : "Ask AI for a suggestion"
|
|
379
397
|
}
|
|
380
398
|
),
|
|
381
|
-
/* @__PURE__ */
|
|
399
|
+
/* @__PURE__ */ a(
|
|
382
400
|
"button",
|
|
383
401
|
{
|
|
384
402
|
type: "button",
|
|
@@ -388,22 +406,31 @@ function ce({
|
|
|
388
406
|
}
|
|
389
407
|
)
|
|
390
408
|
] }),
|
|
391
|
-
|
|
409
|
+
B && /* @__PURE__ */ a("p", { className: "text-[11px] text-red-600 dark:text-red-400", children: B })
|
|
392
410
|
] })
|
|
393
411
|
]
|
|
394
412
|
}
|
|
395
413
|
);
|
|
396
414
|
}
|
|
397
|
-
function
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
415
|
+
function k(r) {
|
|
416
|
+
return `${r.field}|${r.rule}|${r.message ?? ""}`;
|
|
417
|
+
}
|
|
418
|
+
function xe(r) {
|
|
419
|
+
var l;
|
|
420
|
+
const t = r, n = (t == null ? void 0 : t.status) ?? (t == null ? void 0 : t.statusCode) ?? ((l = t == null ? void 0 : t.response) == null ? void 0 : l.status);
|
|
421
|
+
return typeof n == "number" ? n : null;
|
|
422
|
+
}
|
|
423
|
+
function S(r) {
|
|
424
|
+
var n;
|
|
425
|
+
const t = r;
|
|
426
|
+
return String(((n = t == null ? void 0 : t.response) == null ? void 0 : n.error) ?? (t == null ? void 0 : t.message) ?? "Request failed");
|
|
401
427
|
}
|
|
402
428
|
export {
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
429
|
+
ce as OWN_RECORD_WRITES_EVENT,
|
|
430
|
+
Ce as RecordIntegrityBanner,
|
|
431
|
+
ue as findingFieldLabel,
|
|
432
|
+
k as findingKey,
|
|
433
|
+
we as integrityByField,
|
|
434
|
+
Y as ownWritesOf,
|
|
435
|
+
le as useRecordIntegrity
|
|
409
436
|
};
|