@nivaro/react 0.3.10 → 0.3.12
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/useNivaroForm.js +1 -1
- package/dist/hooks/useSessionRecorder.js +109 -102
- package/dist/index.d.ts +34 -3
- package/dist/shared/components/CollectionBrowserView.js +1546 -1477
- package/dist/shared/components/ItemEditForm.js +4332 -4195
- package/dist/shared/components/PageRenderer.js +512 -465
- package/dist/shared/components/ProfileView.js +115 -109
- package/dist/shared/components/QueryStatStrip.js +74 -70
- package/dist/shared/components/ReportView.js +818 -827
- package/dist/shared/components/SheetHeaderBody.js +16 -14
- package/dist/shared/components/chat/ChatPanel.js +492 -472
- package/dist/shared/components/item-edit/CatalogPickerField.js +1029 -933
- package/dist/shared/components/item-edit/FieldRenderer.js +161 -156
- package/dist/shared/components/item-edit/FieldRow.js +20 -19
- package/dist/shared/components/item-edit/FilePickerField.js +52 -40
- package/dist/shared/components/item-edit/GroupSection.js +221 -221
- package/dist/shared/components/item-edit/InlineGridField.js +41 -41
- package/dist/shared/components/item-edit/InlineTableField.js +2249 -2238
- package/dist/shared/components/item-edit/M2MCombobox.js +46 -44
- package/dist/shared/components/item-edit/NestedRelationEditor.js +11 -11
- package/dist/shared/components/item-edit/QuickPicker.js +263 -216
- package/dist/shared/components/item-edit/RelationCombobox.js +285 -245
- package/dist/shared/components/item-edit/RichTextEditorImpl.js +42 -32
- package/dist/shared/components/item-edit/RowHistorySheet.js +130 -134
- package/dist/shared/components/item-edit/SummaryPanel.js +305 -279
- package/dist/shared/components/item-edit/UserChip.js +301 -233
- package/dist/shared/components/item-edit/helpers.js +133 -134
- package/dist/shared/components/item-edit/line-qty.js +57 -0
- package/dist/shared/components/item-edit/option-disambiguate.js +53 -0
- package/dist/shared/components/panels/AddendumLinesDiff.js +87 -90
- package/dist/shared/components/panels/CommentPanel.js +350 -315
- package/dist/shared/components/panels/ItemLockBanner.js +297 -230
- package/dist/shared/components/panels/PipelinePanel.js +719 -701
- package/dist/shared/components/profile/PersonAdminTools.js +168 -144
- package/dist/shared/components/profile/PersonProfile.js +42 -41
- package/dist/shared/components/profile/session-actions.js +52 -0
- package/dist/shared/components/queue/QueueQuickFilters.js +43 -41
- package/dist/shared/components/queue/QueueWorklist.js +1005 -935
- package/dist/shared/components/widgets/ReviewListWidget.js +99 -93
- package/dist/shared/lib/obligation-banner.js +14 -13
- package/dist/shared/lib/obligation-reason-text.js +13 -0
- package/dist/shared/lib/query-filter-seed.js +34 -11
- package/dist/shared/lib/replay-checkout.js +20 -0
- package/dist/shared/lib/sanitize-html.js +24 -15
- package/dist/shared/lib/sheet-def.js +38 -22
- package/dist/shared/lib/unique-options.js +10 -0
- package/dist/shared/lib/utils.js +57 -43
- package/dist/shared/lib/validation-rules.js +58 -34
- package/package.json +1 -1
|
@@ -4,10 +4,11 @@ import { RotateCcw as we, ChevronDown as ee } from "lucide-react";
|
|
|
4
4
|
import { useMemo as $, useState as te, useEffect as Re, Fragment as be } from "react";
|
|
5
5
|
import { get as L } from "../../lib/commands.js";
|
|
6
6
|
import { numericIntlOptions as Ne } from "../../lib/format-value.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
7
|
+
import { htmlToText as Je } from "../../lib/sanitize-html.js";
|
|
8
|
+
import { formatDateTime as ke, formatRelative as ve, cn as j, titleCase as Pe, formatDate as Ve } from "../../lib/utils.js";
|
|
9
|
+
import { Sheet as He, SheetContent as Qe, SheetHeader as We, SheetTitle as Ue } from "../ui/sheet.js";
|
|
10
|
+
import { applyDisplayTemplate as Se, SYSTEM_FIELDS as Ye } from "./helpers.js";
|
|
11
|
+
function Ge(f) {
|
|
11
12
|
const { data: x } = ne({
|
|
12
13
|
queryKey: ["nvr-machine-markers"],
|
|
13
14
|
queryFn: () => f.request(L("/comments/machine-markers")).then((b) => b.data ?? []),
|
|
@@ -16,17 +17,17 @@ function Ye(f) {
|
|
|
16
17
|
});
|
|
17
18
|
return x ?? [];
|
|
18
19
|
}
|
|
19
|
-
function
|
|
20
|
+
function Xe(f) {
|
|
20
21
|
const x = String(f ?? "").trim();
|
|
21
22
|
if (!/^import:/i.test(x)) return null;
|
|
22
23
|
const b = x.slice(7), k = b.lastIndexOf(":"), v = (k >= 0 ? b.slice(0, k) : b).trim() || "a file", N = k >= 0 ? b.slice(k + 1).trim() : "", S = /^run-(\d+)$/i.exec(N);
|
|
23
24
|
return { template: v, fileId: S || !N ? null : N, runId: S ? Number(S[1]) : null };
|
|
24
25
|
}
|
|
25
|
-
function
|
|
26
|
+
function Ze(f, x = []) {
|
|
26
27
|
var N, S;
|
|
27
28
|
const b = String(f ?? "").trim();
|
|
28
29
|
if (!b) return { kind: "none", text: "" };
|
|
29
|
-
const k =
|
|
30
|
+
const k = Xe(b);
|
|
30
31
|
if (k) return { kind: "machine", text: `Imported via ${k.template}`, fileId: k.fileId };
|
|
31
32
|
const v = b.toLowerCase();
|
|
32
33
|
for (const O of x) {
|
|
@@ -37,8 +38,8 @@ function Xe(f, x = []) {
|
|
|
37
38
|
}
|
|
38
39
|
return { kind: "reason", text: b };
|
|
39
40
|
}
|
|
40
|
-
const
|
|
41
|
-
function
|
|
41
|
+
const et = /* @__PURE__ */ new Set(["sort", "created", "updated", "created_at", "updated_at"]), I = (f) => f == null || f === "", tt = (f, x) => I(f) && I(x) ? !0 : typeof f == "object" || typeof x == "object" ? JSON.stringify(f) === JSON.stringify(x) : String(f) === String(x);
|
|
42
|
+
function nt(f) {
|
|
42
43
|
const x = f == null ? void 0 : f.options;
|
|
43
44
|
if (!x) return {};
|
|
44
45
|
if (typeof x == "string")
|
|
@@ -49,7 +50,7 @@ function tt(f) {
|
|
|
49
50
|
}
|
|
50
51
|
return x;
|
|
51
52
|
}
|
|
52
|
-
function
|
|
53
|
+
function ft({
|
|
53
54
|
open: f,
|
|
54
55
|
onOpenChange: x,
|
|
55
56
|
rowTitle: b,
|
|
@@ -61,79 +62,79 @@ function ut({
|
|
|
61
62
|
parentField: F,
|
|
62
63
|
m2oRelMap: D,
|
|
63
64
|
relations: E,
|
|
64
|
-
collection:
|
|
65
|
+
collection: q,
|
|
65
66
|
m2oDisplays: P,
|
|
66
|
-
client:
|
|
67
|
+
client: M,
|
|
67
68
|
allowRestore: re,
|
|
68
69
|
onRestore: _e,
|
|
69
70
|
mode: $e = "row",
|
|
70
71
|
rowLabel: z,
|
|
71
|
-
focusRevisionId:
|
|
72
|
+
focusRevisionId: A = null,
|
|
72
73
|
truncated: je = !1,
|
|
73
|
-
onRestoreAllTo:
|
|
74
|
-
restoringAll:
|
|
74
|
+
onRestoreAllTo: se,
|
|
75
|
+
restoringAll: oe = !1
|
|
75
76
|
}) {
|
|
76
|
-
const ie = Ke(), ae =
|
|
77
|
+
const ie = Ke(), ae = Ge(M), y = $e === "timeline", le = $(() => new Map(S.map((e) => [e.field, e])), [S]), V = $(() => {
|
|
77
78
|
const e = new Map(D);
|
|
78
79
|
for (const t of E) {
|
|
79
80
|
const n = t.many_field;
|
|
80
|
-
!n || t.many_collection !==
|
|
81
|
+
!n || t.many_collection !== q || t.junction_field || !t.one_collection || e.has(n) || e.set(n, t);
|
|
81
82
|
}
|
|
82
83
|
return e;
|
|
83
|
-
}, [D, E,
|
|
84
|
+
}, [D, E, q]), H = $(() => {
|
|
84
85
|
const e = /* @__PURE__ */ new Map();
|
|
85
86
|
return O.forEach((t, n) => e.set(t.field, n)), S.forEach((t, n) => {
|
|
86
87
|
e.has(t.field) || e.set(t.field, O.length + n);
|
|
87
88
|
}), e;
|
|
88
|
-
}, [O, S]), Q = (e) => !
|
|
89
|
-
const n = [...e].sort((
|
|
90
|
-
let
|
|
91
|
-
for (const
|
|
92
|
-
const l = [
|
|
89
|
+
}, [O, S]), Q = (e) => !Ye.has(e) && !et.has(e) && e !== F && !e.startsWith("__"), de = (e, t) => {
|
|
90
|
+
const n = [...e].sort((o, l) => o.id - l.id), r = [];
|
|
91
|
+
let s = null;
|
|
92
|
+
for (const o of n) {
|
|
93
|
+
const l = [o.first_name, o.last_name].filter(Boolean).join(" ") || o.user_email || "System", u = String(o.action ?? "").toLowerCase(), d = u === "create" ? "create" : u === "update" ? "update" : u === "delete" ? "delete" : "other", i = o.data ?? {}, p = [], m = [];
|
|
93
94
|
if (d === "delete") {
|
|
94
|
-
const g =
|
|
95
|
-
for (const [h,
|
|
96
|
-
!Q(h) ||
|
|
97
|
-
} else if (d === "create" || !
|
|
95
|
+
const g = s ?? i;
|
|
96
|
+
for (const [h, C] of Object.entries(g))
|
|
97
|
+
!Q(h) || I(C) || m.push({ field: h, value: C });
|
|
98
|
+
} else if (d === "create" || !s)
|
|
98
99
|
for (const [g, h] of Object.entries(i))
|
|
99
|
-
!Q(g) ||
|
|
100
|
+
!Q(g) || I(h) || m.push({ field: g, value: h });
|
|
100
101
|
else {
|
|
101
|
-
const g =
|
|
102
|
+
const g = o.delta ? Object.keys(o.delta) : Object.keys(i);
|
|
102
103
|
for (const h of g) {
|
|
103
104
|
if (!Q(h)) continue;
|
|
104
|
-
const
|
|
105
|
-
|
|
105
|
+
const C = o.delta ? o.delta[h] : i[h], ye = s[h];
|
|
106
|
+
tt(ye, C) || p.push({ field: h, before: ye, after: C });
|
|
106
107
|
}
|
|
107
108
|
}
|
|
108
|
-
const w = (g, h) => (
|
|
109
|
+
const w = (g, h) => (H.get(g) ?? 9999) - (H.get(h) ?? 9999);
|
|
109
110
|
p.sort((g, h) => w(g.field, h.field)), m.sort((g, h) => w(g.field, h.field)), r.push({
|
|
110
|
-
rev:
|
|
111
|
+
rev: o,
|
|
111
112
|
kind: d,
|
|
112
113
|
who: l,
|
|
113
114
|
changes: p,
|
|
114
115
|
snapshot: m,
|
|
115
|
-
provenance:
|
|
116
|
+
provenance: Ze(o.comment, ae),
|
|
116
117
|
row: t,
|
|
117
|
-
before:
|
|
118
|
-
}), d !== "delete" && Object.keys(i).length > 0 && (
|
|
118
|
+
before: s
|
|
119
|
+
}), d !== "delete" && Object.keys(i).length > 0 && (s = i);
|
|
119
120
|
}
|
|
120
121
|
return r.reverse();
|
|
121
122
|
}, _ = $(() => {
|
|
122
123
|
if (!y) return de(v, null);
|
|
123
124
|
const e = /* @__PURE__ */ new Map();
|
|
124
125
|
for (const n of v) {
|
|
125
|
-
const r = String(n.item_id ?? ""),
|
|
126
|
-
|
|
126
|
+
const r = String(n.item_id ?? ""), s = e.get(r) ?? [];
|
|
127
|
+
s.push(n), e.set(r, s);
|
|
127
128
|
}
|
|
128
129
|
const t = [];
|
|
129
130
|
for (const [n, r] of e) {
|
|
130
|
-
const
|
|
131
|
+
const s = [...r].sort((d, i) => i.id - d.id)[0], o = String((s == null ? void 0 : s.action) ?? "").toLowerCase() === "delete", l = [...r].sort((d, i) => i.id - d.id).find((d) => Object.keys(d.data ?? {}).length > 0), u = (z == null ? void 0 : z(n, (l == null ? void 0 : l.data) ?? (s == null ? void 0 : s.data) ?? {})) ?? { title: `#${n}` };
|
|
131
132
|
t.push(
|
|
132
|
-
...de(r, { itemId: n, title: u.title, subtitle: u.subtitle, deleted:
|
|
133
|
+
...de(r, { itemId: n, title: u.title, subtitle: u.subtitle, deleted: o })
|
|
133
134
|
);
|
|
134
135
|
}
|
|
135
136
|
return t.sort((n, r) => r.rev.id - n.rev.id), t;
|
|
136
|
-
}, [v,
|
|
137
|
+
}, [v, H, F, y, z, ae]), B = $(() => {
|
|
137
138
|
if (!y)
|
|
138
139
|
return _.map((n) => ({
|
|
139
140
|
key: n.rev.id,
|
|
@@ -144,8 +145,8 @@ function ut({
|
|
|
144
145
|
const e = [];
|
|
145
146
|
let t = null;
|
|
146
147
|
for (const n of _) {
|
|
147
|
-
const r = n.rev.timestamp ? new Date(n.rev.timestamp).getTime() : NaN,
|
|
148
|
-
t && t.who === n.who && Number.isFinite(r) && Number.isFinite(
|
|
148
|
+
const r = n.rev.timestamp ? new Date(n.rev.timestamp).getTime() : NaN, s = t != null && t.lastAt ? new Date(t.lastAt).getTime() : NaN;
|
|
149
|
+
t && t.who === n.who && Number.isFinite(r) && Number.isFinite(s) && Math.abs(s - r) <= 5e3 && !t.versions.some((l) => {
|
|
149
150
|
var u, d;
|
|
150
151
|
return ((u = l.row) == null ? void 0 : u.itemId) === ((d = n.row) == null ? void 0 : d.itemId);
|
|
151
152
|
}) && t ? (t.versions.push(n), t.lastAt = n.rev.timestamp) : (t = {
|
|
@@ -160,26 +161,26 @@ function ut({
|
|
|
160
161
|
}, [_, y]), K = $(() => {
|
|
161
162
|
const e = /* @__PURE__ */ new Map();
|
|
162
163
|
for (const t of E)
|
|
163
|
-
t.one_collection ===
|
|
164
|
+
t.one_collection === q && t.one_field && e.set(t.one_field, t);
|
|
164
165
|
return e;
|
|
165
|
-
}, [E,
|
|
166
|
+
}, [E, q]), ce = (e, t) => {
|
|
166
167
|
if (t == null) return null;
|
|
167
168
|
if (typeof t != "object") return String(t);
|
|
168
169
|
const n = t;
|
|
169
170
|
if (e.junction_field && n[e.junction_field] != null) return String(n[e.junction_field]);
|
|
170
|
-
const r = Object.keys(n).filter((
|
|
171
|
+
const r = Object.keys(n).filter((s) => s !== "id" && s !== e.many_field);
|
|
171
172
|
return r.length === 1 && n[r[0]] != null && typeof n[r[0]] != "object" ? String(n[r[0]]) : n.id != null ? String(n.id) : null;
|
|
172
173
|
}, R = $(() => {
|
|
173
174
|
const e = /* @__PURE__ */ new Map(), t = (n, r) => {
|
|
174
175
|
if (!Array.isArray(r)) return;
|
|
175
|
-
const
|
|
176
|
-
if (!
|
|
177
|
-
const
|
|
176
|
+
const s = K.get(n);
|
|
177
|
+
if (!s) return;
|
|
178
|
+
const o = e.get(n) ?? /* @__PURE__ */ new Set();
|
|
178
179
|
for (const l of r) {
|
|
179
|
-
const u = ce(
|
|
180
|
-
u != null &&
|
|
180
|
+
const u = ce(s, l);
|
|
181
|
+
u != null && o.add(u);
|
|
181
182
|
}
|
|
182
|
-
|
|
183
|
+
o.size && e.set(n, o);
|
|
183
184
|
};
|
|
184
185
|
for (const n of _) {
|
|
185
186
|
for (const r of n.changes)
|
|
@@ -190,29 +191,29 @@ function ut({
|
|
|
190
191
|
}, [_, K]), Oe = $(
|
|
191
192
|
() => [...R.entries()].map(([e, t]) => `${e}:${[...t].sort().join(",")}`).sort().join("|"),
|
|
192
193
|
[R]
|
|
193
|
-
), { data:
|
|
194
|
-
queryKey: ["row-history-alias-labels",
|
|
194
|
+
), { data: Te = {} } = ne({
|
|
195
|
+
queryKey: ["row-history-alias-labels", q, Oe],
|
|
195
196
|
queryFn: async () => {
|
|
196
197
|
const e = {}, t = (n) => ie.fetchQuery({
|
|
197
198
|
queryKey: ["collection-meta", n],
|
|
198
|
-
queryFn: () =>
|
|
199
|
+
queryFn: () => M.request(L(`/collections/${n}`)).then((r) => r.data),
|
|
199
200
|
staleTime: 6e5
|
|
200
201
|
});
|
|
201
202
|
return await Promise.all(
|
|
202
203
|
[...R.entries()].map(async ([n, r]) => {
|
|
203
|
-
const
|
|
204
|
-
if (!
|
|
205
|
-
let
|
|
206
|
-
if (
|
|
207
|
-
const m = await t(
|
|
208
|
-
(g) => g.many_collection ===
|
|
204
|
+
const s = K.get(n);
|
|
205
|
+
if (!s) return;
|
|
206
|
+
let o = null;
|
|
207
|
+
if (s.junction_field && s.many_collection) {
|
|
208
|
+
const m = await t(s.many_collection).catch(() => null), w = ((m == null ? void 0 : m.relations) ?? []).find(
|
|
209
|
+
(g) => g.many_collection === s.many_collection && g.many_field === s.junction_field
|
|
209
210
|
);
|
|
210
|
-
|
|
211
|
+
o = (w == null ? void 0 : w.one_collection) ?? null;
|
|
211
212
|
} else
|
|
212
|
-
|
|
213
|
-
if (!
|
|
214
|
-
const l = await t(
|
|
215
|
-
L(`/items/${
|
|
213
|
+
o = s.many_collection ?? null;
|
|
214
|
+
if (!o) return;
|
|
215
|
+
const l = await t(o).catch(() => null), u = (l == null ? void 0 : l.display_template) ?? void 0, d = u ? [...u.matchAll(/\{\{([\w.]+)\}\}/g)].map((m) => m[1]) : [], i = d.some((m) => m.includes(".")) ? ["id", ...d].join(",") : void 0, p = await M.request(
|
|
216
|
+
L(`/items/${o}`, {
|
|
216
217
|
filter: JSON.stringify({ id: { _in: [...r] } }),
|
|
217
218
|
limit: r.size,
|
|
218
219
|
...i ? { fields: i } : {}
|
|
@@ -231,11 +232,11 @@ function ut({
|
|
|
231
232
|
}), J = $(() => {
|
|
232
233
|
const e = /* @__PURE__ */ new Map(), t = (n, r) => {
|
|
233
234
|
var l;
|
|
234
|
-
if (
|
|
235
|
-
const
|
|
236
|
-
if (!(
|
|
237
|
-
const
|
|
238
|
-
|
|
235
|
+
if (I(r) || typeof r == "object") return;
|
|
236
|
+
const s = V.get(n);
|
|
237
|
+
if (!(s != null && s.one_collection) || (l = P[s.one_collection]) != null && l[String(r)]) return;
|
|
238
|
+
const o = e.get(s.one_collection) ?? /* @__PURE__ */ new Set();
|
|
239
|
+
o.add(String(r)), e.set(s.one_collection, o);
|
|
239
240
|
};
|
|
240
241
|
for (const n of _) {
|
|
241
242
|
for (const r of n.changes)
|
|
@@ -243,22 +244,22 @@ function ut({
|
|
|
243
244
|
for (const r of n.snapshot) t(r.field, r.value);
|
|
244
245
|
}
|
|
245
246
|
return e;
|
|
246
|
-
}, [_,
|
|
247
|
+
}, [_, V, P]), Ie = $(
|
|
247
248
|
() => [...J.entries()].map(([e, t]) => `${e}:${[...t].sort().join(",")}`).sort().join("|"),
|
|
248
249
|
[J]
|
|
249
250
|
), { data: Fe = {} } = ne({
|
|
250
|
-
queryKey: ["row-history-labels",
|
|
251
|
+
queryKey: ["row-history-labels", Ie],
|
|
251
252
|
queryFn: async () => {
|
|
252
253
|
const e = {};
|
|
253
254
|
return await Promise.all(
|
|
254
255
|
[...J.entries()].map(async ([t, n]) => {
|
|
255
256
|
const r = await ie.fetchQuery({
|
|
256
257
|
queryKey: ["collection-display-meta", t],
|
|
257
|
-
queryFn: () =>
|
|
258
|
+
queryFn: () => M.request(
|
|
258
259
|
L(`/collections/${t}`)
|
|
259
260
|
).then((d) => d.data),
|
|
260
261
|
staleTime: 6e5
|
|
261
|
-
}),
|
|
262
|
+
}), s = (r == null ? void 0 : r.display_template) ?? void 0, o = s ? [...s.matchAll(/\{\{([\w.]+)\}\}/g)].map((d) => d[1]) : [], l = o.some((d) => d.includes(".")) ? ["id", ...o].join(",") : void 0, u = await M.request(
|
|
262
263
|
L(`/items/${t}`, {
|
|
263
264
|
filter: JSON.stringify({ id: { _in: [...n] } }),
|
|
264
265
|
limit: n.size,
|
|
@@ -266,21 +267,21 @@ function ut({
|
|
|
266
267
|
})
|
|
267
268
|
).then((d) => d.data ?? []);
|
|
268
269
|
e[t] = {};
|
|
269
|
-
for (const d of u) e[t][String(d.id)] = Se(
|
|
270
|
+
for (const d of u) e[t][String(d.id)] = Se(s, d);
|
|
270
271
|
})
|
|
271
272
|
), e;
|
|
272
273
|
},
|
|
273
274
|
enabled: f && J.size > 0,
|
|
274
275
|
staleTime: 5 * 6e4
|
|
275
|
-
}),
|
|
276
|
+
}), T = (e) => {
|
|
276
277
|
const t = le.get(e);
|
|
277
|
-
return (t == null ? void 0 : t.label) ||
|
|
278
|
+
return (t == null ? void 0 : t.label) || Pe(e);
|
|
278
279
|
}, W = (e, t) => {
|
|
279
280
|
var u, d;
|
|
280
|
-
if (
|
|
281
|
-
const n = le.get(e), r =
|
|
282
|
-
if (
|
|
283
|
-
const i = ((u = P[
|
|
281
|
+
if (I(t)) return { text: "—" };
|
|
282
|
+
const n = le.get(e), r = nt(n), s = V.get(e);
|
|
283
|
+
if (s != null && s.one_collection) {
|
|
284
|
+
const i = ((u = P[s.one_collection]) == null ? void 0 : u[String(t)]) ?? ((d = Fe[s.one_collection]) == null ? void 0 : d[String(t)]);
|
|
284
285
|
return i ? { text: i } : { text: `#${String(t)}`, mono: !0 };
|
|
285
286
|
}
|
|
286
287
|
if (typeof t == "boolean" || (n == null ? void 0 : n.type) === "boolean")
|
|
@@ -291,7 +292,7 @@ function ut({
|
|
|
291
292
|
const m = t.map((w) => {
|
|
292
293
|
var h;
|
|
293
294
|
const g = ce(i, w);
|
|
294
|
-
return g == null ? null : ((h =
|
|
295
|
+
return g == null ? null : ((h = Te[e]) == null ? void 0 : h[g]) ?? `#${g}`;
|
|
295
296
|
}).filter((w) => !!w);
|
|
296
297
|
return m.length ? { text: m.join(", ") } : { text: "—" };
|
|
297
298
|
}
|
|
@@ -301,7 +302,7 @@ function ut({
|
|
|
301
302
|
};
|
|
302
303
|
}
|
|
303
304
|
if (typeof t == "object") return { text: JSON.stringify(t), mono: !0 };
|
|
304
|
-
const
|
|
305
|
+
const o = (n == null ? void 0 : n.type) ?? "";
|
|
305
306
|
if (r.format === "currency" && Number.isFinite(Number(t)))
|
|
306
307
|
return {
|
|
307
308
|
text: Number(t).toLocaleString("en-US", {
|
|
@@ -310,41 +311,36 @@ function ut({
|
|
|
310
311
|
}),
|
|
311
312
|
mono: !0
|
|
312
313
|
};
|
|
313
|
-
if (/^(date|dateTime|datetime|timestamp)$/i.test(
|
|
314
|
+
if (/^(date|dateTime|datetime|timestamp)$/i.test(o)) {
|
|
314
315
|
const i = String(t);
|
|
315
|
-
return { text: /^\d{4}-\d{2}-\d{2}$/.test(i) ?
|
|
316
|
+
return { text: /^\d{4}-\d{2}-\d{2}$/.test(i) ? Ve(i) : ke(i), mono: !0 };
|
|
316
317
|
}
|
|
317
|
-
if (typeof t == "number" || /^(integer|decimal|float|bigInteger|money)$/i.test(
|
|
318
|
+
if (typeof t == "number" || /^(integer|decimal|float|bigInteger|money)$/i.test(o) && Number.isFinite(Number(t)))
|
|
318
319
|
return { text: Number(t).toLocaleString("en-US", Ne(r)), mono: !0 };
|
|
319
320
|
const l = String(t);
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
if (i)
|
|
323
|
-
return i.innerHTML = l, { text: (i.textContent || "").trim() || "—" };
|
|
324
|
-
}
|
|
325
|
-
return { text: l };
|
|
326
|
-
}, [Me, qe] = te(/* @__PURE__ */ new Set()), Ce = (e) => qe((t) => {
|
|
321
|
+
return /<[a-z][\s\S]*>/i.test(l) ? { text: Je(l).trim() || "—" } : { text: l };
|
|
322
|
+
}, [qe, Me] = te(/* @__PURE__ */ new Set()), Ae = (e) => Me((t) => {
|
|
327
323
|
const n = new Set(t);
|
|
328
324
|
return n.has(e) ? n.delete(e) : n.add(e), n;
|
|
329
|
-
}), [
|
|
325
|
+
}), [Ce, ue] = te(/* @__PURE__ */ new Set()), me = (e) => ue((t) => {
|
|
330
326
|
const n = new Set(t);
|
|
331
327
|
return n.has(e) ? n.delete(e) : n.add(e), n;
|
|
332
328
|
}), U = 4, [fe, Y] = te(null);
|
|
333
329
|
Re(() => {
|
|
334
|
-
if (!f ||
|
|
330
|
+
if (!f || A == null || N) {
|
|
335
331
|
f || Y(null);
|
|
336
332
|
return;
|
|
337
333
|
}
|
|
338
|
-
const e = B.find((r) => r.versions.some((
|
|
339
|
-
e && e.versions.length > U && ue((r) => r.has(e.key) ? r : new Set(r).add(e.key)), Y(
|
|
334
|
+
const e = B.find((r) => r.versions.some((s) => s.rev.id === A));
|
|
335
|
+
e && e.versions.length > U && ue((r) => r.has(e.key) ? r : new Set(r).add(e.key)), Y(A);
|
|
340
336
|
const t = window.setTimeout(() => {
|
|
341
|
-
const r = document.querySelector(`[data-rev-id="${
|
|
337
|
+
const r = document.querySelector(`[data-rev-id="${A}"]`);
|
|
342
338
|
r == null || r.scrollIntoView({ block: "center", behavior: "smooth" });
|
|
343
339
|
}, 60), n = window.setTimeout(() => Y(null), 3200);
|
|
344
340
|
return () => {
|
|
345
341
|
window.clearTimeout(t), window.clearTimeout(n);
|
|
346
342
|
};
|
|
347
|
-
}, [f,
|
|
343
|
+
}, [f, A, N, B]);
|
|
348
344
|
const Le = (e) => {
|
|
349
345
|
const t = y && e.row ? e.row.title : "this line";
|
|
350
346
|
if (e.kind === "create") return `added ${t}`;
|
|
@@ -352,12 +348,12 @@ function ut({
|
|
|
352
348
|
if (e.changes.length === 0)
|
|
353
349
|
return !e.before && y ? `saved ${t}` : y ? `saved ${t} without changes` : "saved it without changes";
|
|
354
350
|
const n = y ? ` on ${t}` : "";
|
|
355
|
-
return e.changes.length === 1 ? `changed ${
|
|
351
|
+
return e.changes.length === 1 ? `changed ${T(e.changes[0].field)}${n}` : e.changes.length === 2 ? `changed ${T(e.changes[0].field)} and ${T(e.changes[1].field)}${n}` : `changed ${e.changes.length} fields${n}`;
|
|
356
352
|
}, De = (e) => {
|
|
357
|
-
const t = e.versions.filter((l) => l.kind === "create").length, n = e.versions.filter((l) => l.kind === "delete").length, r = e.versions.length - t - n,
|
|
358
|
-
t &&
|
|
359
|
-
const
|
|
360
|
-
return `saved ${
|
|
353
|
+
const t = e.versions.filter((l) => l.kind === "create").length, n = e.versions.filter((l) => l.kind === "delete").length, r = e.versions.length - t - n, s = [];
|
|
354
|
+
t && s.push(`added ${t}`), r && s.push(`changed ${r}`), n && s.push(`deleted ${n}`);
|
|
355
|
+
const o = e.versions.length;
|
|
356
|
+
return `saved ${o} ${o === 1 ? "line" : "lines"} · ${s.join(", ")}`;
|
|
361
357
|
}, Ee = (e) => {
|
|
362
358
|
var t, n;
|
|
363
359
|
return {
|
|
@@ -365,7 +361,7 @@ function ut({
|
|
|
365
361
|
rowDeleted: !!((n = e.row) != null && n.deleted)
|
|
366
362
|
};
|
|
367
363
|
}, he = (e) => {
|
|
368
|
-
const t =
|
|
364
|
+
const t = qe.has(e.rev.id), n = 6, r = t ? e.snapshot : e.snapshot.slice(0, n), s = e.snapshot.length - r.length;
|
|
369
365
|
return /* @__PURE__ */ c(Z, { children: [
|
|
370
366
|
e.provenance.kind === "machine" && /* @__PURE__ */ c("p", { className: "mt-0.5 text-[11.5px] text-muted-foreground", children: [
|
|
371
367
|
e.provenance.text,
|
|
@@ -387,10 +383,10 @@ function ut({
|
|
|
387
383
|
/* @__PURE__ */ a("span", { className: "text-muted-foreground", children: "Reason: " }),
|
|
388
384
|
e.provenance.text
|
|
389
385
|
] }),
|
|
390
|
-
e.changes.length > 0 && /* @__PURE__ */ a("dl", { className: "mt-2 grid grid-cols-[minmax(96px,max-content)_1fr] gap-x-4 gap-y-1.5 text-[12px] leading-5", children: e.changes.map((
|
|
391
|
-
const l = W(
|
|
386
|
+
e.changes.length > 0 && /* @__PURE__ */ a("dl", { className: "mt-2 grid grid-cols-[minmax(96px,max-content)_1fr] gap-x-4 gap-y-1.5 text-[12px] leading-5", children: e.changes.map((o) => {
|
|
387
|
+
const l = W(o.field, o.before), u = W(o.field, o.after);
|
|
392
388
|
return /* @__PURE__ */ c(be, { children: [
|
|
393
|
-
/* @__PURE__ */ a("dt", { className: "truncate text-muted-foreground", title:
|
|
389
|
+
/* @__PURE__ */ a("dt", { className: "truncate text-muted-foreground", title: T(o.field), children: T(o.field) }),
|
|
394
390
|
/* @__PURE__ */ c("dd", { className: "flex min-w-0 flex-wrap items-baseline gap-x-1.5", children: [
|
|
395
391
|
/* @__PURE__ */ a(
|
|
396
392
|
"span",
|
|
@@ -416,7 +412,7 @@ function ut({
|
|
|
416
412
|
}
|
|
417
413
|
)
|
|
418
414
|
] })
|
|
419
|
-
] },
|
|
415
|
+
] }, o.field);
|
|
420
416
|
}) }),
|
|
421
417
|
e.snapshot.length > 0 && /* @__PURE__ */ c(Z, { children: [
|
|
422
418
|
/* @__PURE__ */ a(
|
|
@@ -426,10 +422,10 @@ function ut({
|
|
|
426
422
|
"mt-2 grid grid-cols-[minmax(96px,max-content)_1fr] gap-x-4 gap-y-1 text-[12px] leading-5",
|
|
427
423
|
e.kind === "delete" && "text-muted-foreground"
|
|
428
424
|
),
|
|
429
|
-
children: r.map((
|
|
430
|
-
const l = W(
|
|
425
|
+
children: r.map((o) => {
|
|
426
|
+
const l = W(o.field, o.value);
|
|
431
427
|
return /* @__PURE__ */ c(be, { children: [
|
|
432
|
-
/* @__PURE__ */ a("dt", { className: "truncate text-muted-foreground", title:
|
|
428
|
+
/* @__PURE__ */ a("dt", { className: "truncate text-muted-foreground", title: T(o.field), children: T(o.field) }),
|
|
433
429
|
/* @__PURE__ */ a(
|
|
434
430
|
"dd",
|
|
435
431
|
{
|
|
@@ -441,15 +437,15 @@ function ut({
|
|
|
441
437
|
children: l.text
|
|
442
438
|
}
|
|
443
439
|
)
|
|
444
|
-
] },
|
|
440
|
+
] }, o.field);
|
|
445
441
|
})
|
|
446
442
|
}
|
|
447
443
|
),
|
|
448
|
-
(
|
|
444
|
+
(s > 0 || t) && e.snapshot.length > n && /* @__PURE__ */ c(
|
|
449
445
|
"button",
|
|
450
446
|
{
|
|
451
447
|
type: "button",
|
|
452
|
-
onClick: () =>
|
|
448
|
+
onClick: () => Ae(e.rev.id),
|
|
453
449
|
className: "mt-1.5 inline-flex items-center gap-1 text-[11.5px] font-medium text-muted-foreground transition-colors duration-150 hover:text-foreground",
|
|
454
450
|
"aria-expanded": t,
|
|
455
451
|
children: [
|
|
@@ -463,7 +459,7 @@ function ut({
|
|
|
463
459
|
"aria-hidden": "true"
|
|
464
460
|
}
|
|
465
461
|
),
|
|
466
|
-
t ? "Show fewer" : `Show ${
|
|
462
|
+
t ? "Show fewer" : `Show ${s} more ${s === 1 ? "field" : "fields"}`
|
|
467
463
|
]
|
|
468
464
|
}
|
|
469
465
|
)
|
|
@@ -481,9 +477,9 @@ function ut({
|
|
|
481
477
|
var t;
|
|
482
478
|
return G.get(((t = e.row) == null ? void 0 : t.itemId) ?? "") === e.rev.id;
|
|
483
479
|
}, ge = (e, t) => {
|
|
484
|
-
var
|
|
480
|
+
var s;
|
|
485
481
|
if (!pe(e, t)) return null;
|
|
486
|
-
const n = e.kind === "delete" || !!((
|
|
482
|
+
const n = e.kind === "delete" || !!((s = e.row) != null && s.deleted), r = e.kind === "delete" ? Object.fromEntries(e.snapshot.map((o) => [o.field, o.value])) : e.rev.data;
|
|
487
483
|
return /* @__PURE__ */ c(
|
|
488
484
|
"button",
|
|
489
485
|
{
|
|
@@ -509,9 +505,9 @@ function ut({
|
|
|
509
505
|
),
|
|
510
506
|
!n && /* @__PURE__ */ a("span", { className: "absolute bottom-[-24px] top-[11px] w-px bg-border" })
|
|
511
507
|
] }), X = _.length, Be = y ? `${X} ${X === 1 ? "version" : "versions"} across ${G.size} ${G.size === 1 ? "line" : "lines"}` : `${v.length} ${v.length === 1 ? "version" : "versions"}`;
|
|
512
|
-
return /* @__PURE__ */ a(He, { open: f, onOpenChange: x, children: /* @__PURE__ */ c(
|
|
513
|
-
/* @__PURE__ */ c(
|
|
514
|
-
/* @__PURE__ */ a(
|
|
508
|
+
return /* @__PURE__ */ a(He, { open: f, onOpenChange: x, children: /* @__PURE__ */ c(Qe, { className: "flex w-[560px] flex-col gap-0 p-0 sm:max-w-[560px]", children: [
|
|
509
|
+
/* @__PURE__ */ c(We, { className: "shrink-0 border-b border-border px-6 pb-4 pt-5 text-left", children: [
|
|
510
|
+
/* @__PURE__ */ a(Ue, { className: "text-[14px] font-semibold", children: y ? "Lines timeline" : "Row history" }),
|
|
515
511
|
/* @__PURE__ */ c("p", { className: "mt-0.5 flex min-w-0 items-baseline gap-2 text-[12px] text-muted-foreground", children: [
|
|
516
512
|
/* @__PURE__ */ a("span", { className: "shrink-0 font-medium text-foreground", children: b }),
|
|
517
513
|
k && /* @__PURE__ */ a("span", { className: "truncate", children: k }),
|
|
@@ -531,21 +527,21 @@ function ut({
|
|
|
531
527
|
/* @__PURE__ */ a("p", { className: "mt-1 text-[12px] text-muted-foreground", children: y ? "Every line added, changed or removed on this record will be listed here." : "Every save of this line will be listed here with what changed." })
|
|
532
528
|
] }) : /* @__PURE__ */ a("ol", { className: "relative", children: B.map((e, t) => {
|
|
533
529
|
var d;
|
|
534
|
-
const n = t === 0, r = t === B.length - 1,
|
|
530
|
+
const n = t === 0, r = t === B.length - 1, s = e.at ? ke(e.at) : "", o = e.versions.length > 1, l = o && e.versions.length > U && !Ce.has(e.key), u = y && re && se && !n && e.at ? /* @__PURE__ */ c(
|
|
535
531
|
"button",
|
|
536
532
|
{
|
|
537
533
|
type: "button",
|
|
538
|
-
disabled:
|
|
539
|
-
onClick: () =>
|
|
534
|
+
disabled: oe,
|
|
535
|
+
onClick: () => se(e.at),
|
|
540
536
|
className: "ml-auto inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[11px] font-medium text-muted-foreground transition-colors duration-150 hover:bg-muted hover:text-foreground disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan",
|
|
541
537
|
"data-tip": "Put every line back to how it stood right after this save — writes immediately",
|
|
542
538
|
children: [
|
|
543
539
|
/* @__PURE__ */ a(we, { className: "h-3 w-3", "aria-hidden": "true" }),
|
|
544
|
-
|
|
540
|
+
oe ? "Restoring…" : "All lines to here"
|
|
545
541
|
]
|
|
546
542
|
}
|
|
547
543
|
) : null;
|
|
548
|
-
if (!
|
|
544
|
+
if (!o) {
|
|
549
545
|
const i = e.versions[0], p = n;
|
|
550
546
|
return /* @__PURE__ */ c(
|
|
551
547
|
"li",
|
|
@@ -567,7 +563,7 @@ function ut({
|
|
|
567
563
|
i.row.subtitle
|
|
568
564
|
] }),
|
|
569
565
|
/* @__PURE__ */ a("span", { className: "text-muted-foreground", children: "·" }),
|
|
570
|
-
/* @__PURE__ */ a("span", { className: "text-muted-foreground", "data-tip":
|
|
566
|
+
/* @__PURE__ */ a("span", { className: "text-muted-foreground", "data-tip": s || void 0, children: i.rev.timestamp ? ve(i.rev.timestamp) : "" }),
|
|
571
567
|
p && !y && /* @__PURE__ */ a("span", { className: "ml-auto rounded-full bg-nvr-cyan/10 px-2 py-px text-[10.5px] font-medium text-[#0b7ea6] dark:text-nvr-cyan", children: "Current" }),
|
|
572
568
|
(pe(i, p) || u) && /* @__PURE__ */ c("span", { className: "ml-auto inline-flex items-center gap-1", children: [
|
|
573
569
|
ge(i, p),
|
|
@@ -593,7 +589,7 @@ function ut({
|
|
|
593
589
|
/* @__PURE__ */ a("span", { className: "font-semibold text-foreground", children: e.who }),
|
|
594
590
|
/* @__PURE__ */ a("span", { className: "text-muted-foreground", children: De(e) }),
|
|
595
591
|
/* @__PURE__ */ a("span", { className: "text-muted-foreground", children: "·" }),
|
|
596
|
-
/* @__PURE__ */ a("span", { className: "text-muted-foreground", "data-tip":
|
|
592
|
+
/* @__PURE__ */ a("span", { className: "text-muted-foreground", "data-tip": s || void 0, children: e.at ? ve(e.at) : "" }),
|
|
597
593
|
u
|
|
598
594
|
] }),
|
|
599
595
|
l ? /* @__PURE__ */ c(
|
|
@@ -633,7 +629,7 @@ function ut({
|
|
|
633
629
|
children: ((p = i.row) == null ? void 0 : p.title) ?? "Line"
|
|
634
630
|
}
|
|
635
631
|
),
|
|
636
|
-
/* @__PURE__ */ a("span", { className: "text-muted-foreground", children: i.kind === "create" ? "added" : i.kind === "delete" ? "deleted" : i.changes.length === 0 ? "saved" : `${i.changes.map((w) =>
|
|
632
|
+
/* @__PURE__ */ a("span", { className: "text-muted-foreground", children: i.kind === "create" ? "added" : i.kind === "delete" ? "deleted" : i.changes.length === 0 ? "saved" : `${i.changes.map((w) => T(w.field)).slice(0, 3).join(
|
|
637
633
|
", "
|
|
638
634
|
)}${i.changes.length > 3 ? ` +${i.changes.length - 3}` : ""}` }),
|
|
639
635
|
((m = i.row) == null ? void 0 : m.subtitle) && /* @__PURE__ */ c("span", { className: "truncate text-muted-foreground", children: [
|
|
@@ -671,8 +667,8 @@ function ut({
|
|
|
671
667
|
] }) });
|
|
672
668
|
}
|
|
673
669
|
export {
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
670
|
+
ft as RowHistorySheet,
|
|
671
|
+
Xe as parseImportStamp,
|
|
672
|
+
Ze as provenanceOf,
|
|
673
|
+
Ge as useMachineMarkers
|
|
678
674
|
};
|