@nivaro/react 0.3.50 → 0.3.52
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/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +13 -3
- package/dist/shared/components/ItemEditForm.js +4801 -4666
- package/dist/shared/components/QueryTable.js +337 -324
- package/dist/shared/components/ReportView.js +105 -99
- package/dist/shared/components/alerts/AlertManagerView.js +327 -301
- package/dist/shared/components/item-edit/CatalogPickerField.js +1149 -1111
- package/dist/shared/components/item-edit/DraftRecoveryBanner.js +58 -53
- package/dist/shared/components/item-edit/FieldRenderer.js +227 -223
- package/dist/shared/components/item-edit/FieldRow.js +287 -265
- package/dist/shared/components/item-edit/FilePickerField.js +315 -307
- package/dist/shared/components/item-edit/InlineTableField.js +491 -466
- package/dist/shared/components/item-edit/RecordHeaderActions.js +76 -75
- package/dist/shared/components/item-edit/RecordLiveSync.js +93 -91
- package/dist/shared/components/item-edit/RelationCombobox.js +62 -60
- package/dist/shared/components/item-edit/SummaryPanel.js +287 -277
- package/dist/shared/components/item-edit/UserChip.js +233 -200
- package/dist/shared/components/item-edit/header-midair.js +51 -0
- package/dist/shared/components/item-edit/line-midair.js +76 -70
- package/dist/shared/components/panels/CommentPanel.js +290 -284
- package/dist/shared/components/panels/ItemLockBanner.js +30 -30
- package/dist/shared/components/panels/PipelinePanel.js +956 -901
- package/dist/shared/components/panels/TaskPanel.js +71 -61
- package/dist/shared/components/panels/TransitionRequirementsDialog.js +569 -439
- package/dist/shared/components/panels/requirement-side-effects.js +40 -0
- package/dist/shared/components/queue/QueueWorklist.js +141 -130
- package/dist/shared/lib/draft-store.js +48 -34
- package/dist/shared/lib/query-stats.js +60 -60
- package/package.json +1 -1
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
function l(e) {
|
|
2
|
+
const n = { ...e.draft }, i = { ...e.initial }, t = [], f = [];
|
|
3
|
+
for (const r of e.conflicts)
|
|
4
|
+
i[r.field] = r.current_value, e.takeTheirs.has(r.field) ? (n[r.field] = r.current_value, t.push(r.field)) : (e.mine[r.field] !== void 0 && (n[r.field] = e.mine[r.field]), f.push(r.field));
|
|
5
|
+
return { draft: n, initial: i, theirs: t, kept: f };
|
|
6
|
+
}
|
|
7
|
+
function o(e, n) {
|
|
8
|
+
return e === n || e == null && n == null ? !0 : e == null || n == null ? !1 : typeof e == "string" && typeof n == "number" || typeof e == "number" && typeof n == "string" ? String(e) === String(n) : JSON.stringify(e) === JSON.stringify(n);
|
|
9
|
+
}
|
|
10
|
+
function u(e) {
|
|
11
|
+
const n = e.base ?? {}, i = [];
|
|
12
|
+
for (const [t, f] of Object.entries(e.fields))
|
|
13
|
+
t in n && (o(n[t], e.current[t]) || o(f, e.current[t]) || i.push({ field: t, current_value: e.current[t] }));
|
|
14
|
+
return i;
|
|
15
|
+
}
|
|
16
|
+
function c(e) {
|
|
17
|
+
const n = [];
|
|
18
|
+
for (const [i, t] of e.guard)
|
|
19
|
+
i in e.payload && (o(t, e.current[i]) || o(e.payload[i], e.current[i]) || n.push({ field: i, current_value: e.current[i] }));
|
|
20
|
+
return n;
|
|
21
|
+
}
|
|
22
|
+
function s(e) {
|
|
23
|
+
return e.conflicts.filter((n) => !(n.field in e.payload && o(e.payload[n.field], n.current_value) || e.decided.has(n.field) && o(e.decided.get(n.field), n.current_value)));
|
|
24
|
+
}
|
|
25
|
+
function d(e) {
|
|
26
|
+
const n = Object.keys(e.payload).filter((t) => !t.startsWith("_"));
|
|
27
|
+
if (n.length === 0) return !1;
|
|
28
|
+
const i = new Set(
|
|
29
|
+
e.conflicts.filter((t) => t.field in e.payload && o(e.payload[t.field], t.current_value)).map((t) => t.field)
|
|
30
|
+
);
|
|
31
|
+
return n.every((t) => i.has(t));
|
|
32
|
+
}
|
|
33
|
+
function a(e, n) {
|
|
34
|
+
return Object.assign(new Error("Someone else changed this record since your draft"), {
|
|
35
|
+
status: 409,
|
|
36
|
+
response: {
|
|
37
|
+
code: "MIDAIR_COLLISION",
|
|
38
|
+
message: "Someone else changed this record since your draft was saved",
|
|
39
|
+
conflicts: e,
|
|
40
|
+
latest_revision: n ?? 0
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
export {
|
|
45
|
+
a as clientMidairError,
|
|
46
|
+
s as conflictsNeedingPerson,
|
|
47
|
+
l as resolveHeaderCollision,
|
|
48
|
+
c as restoredDraftCollisions,
|
|
49
|
+
d as saveIsEcho,
|
|
50
|
+
u as staleDraftConflicts
|
|
51
|
+
};
|
|
@@ -1,50 +1,56 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var m = (
|
|
1
|
+
var q = Object.defineProperty;
|
|
2
|
+
var _ = (s, t, n) => t in s ? q(s, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : s[t] = n;
|
|
3
|
+
var m = (s, t, n) => _(s, typeof t != "symbol" ? t + "" : t, n);
|
|
4
4
|
import { patch as b, get as h } from "../../lib/commands.js";
|
|
5
5
|
import { midairCollisionOf as d } from "../../lib/record-outbox.js";
|
|
6
|
-
function
|
|
7
|
-
return typeof t != "number" || !Number.isFinite(t) || t <= 0 ?
|
|
6
|
+
function S(s, t) {
|
|
7
|
+
return typeof t != "number" || !Number.isFinite(t) || t <= 0 ? s : { ...s, _base_revision: t };
|
|
8
8
|
}
|
|
9
|
-
function B(
|
|
10
|
-
return `${
|
|
9
|
+
function B(s, t) {
|
|
10
|
+
return `${s.key}\0${s.rowId}\0${t}`;
|
|
11
11
|
}
|
|
12
|
-
function C(
|
|
12
|
+
function C(s, t) {
|
|
13
13
|
const n = {};
|
|
14
|
-
for (const [
|
|
15
|
-
return Object.keys(n).some((
|
|
14
|
+
for (const [r, e] of Object.entries(s)) t.has(r) || (n[r] = e);
|
|
15
|
+
return Object.keys(n).some((r) => r !== "_change_reason" && r !== "__flush_early") ? n : null;
|
|
16
16
|
}
|
|
17
|
-
function N(
|
|
18
|
-
const
|
|
19
|
-
|
|
17
|
+
function N(s, t, n, i) {
|
|
18
|
+
const r = s.findIndex((a) => String(a.id) === String(t)), e = r >= 0 ? s[r] : void 0, o = (e == null ? void 0 : e[n || "line_number"]) ?? (e == null ? void 0 : e.line_number);
|
|
19
|
+
if (o != null && o !== "") return `Line ${String(o)}`;
|
|
20
|
+
if (e) {
|
|
21
|
+
const a = e.year;
|
|
22
|
+
if ((typeof a == "number" || typeof a == "string") && /^\d{4}$/.test(String(a)))
|
|
23
|
+
return `Year ${String(a)}`;
|
|
24
|
+
}
|
|
25
|
+
return r >= 0 ? `Line ${r + 1}` : `Row ${t}`;
|
|
20
26
|
}
|
|
21
27
|
const w = 500;
|
|
22
|
-
function k(
|
|
28
|
+
function k(s) {
|
|
23
29
|
var n;
|
|
24
|
-
const t =
|
|
30
|
+
const t = s;
|
|
25
31
|
return ((t == null ? void 0 : t.status) ?? ((n = t == null ? void 0 : t.response) == null ? void 0 : n.status)) === 404;
|
|
26
32
|
}
|
|
27
|
-
async function
|
|
28
|
-
const i = /* @__PURE__ */ new Map(),
|
|
33
|
+
async function $(s, t, n) {
|
|
34
|
+
const i = /* @__PURE__ */ new Map(), r = [...new Set(n.map(String))].filter(
|
|
29
35
|
(e) => e && e !== "new" && !e.startsWith("pending:")
|
|
30
36
|
);
|
|
31
|
-
for (let e = 0; e <
|
|
32
|
-
const o =
|
|
37
|
+
for (let e = 0; e < r.length; e += w) {
|
|
38
|
+
const o = r.slice(e, e + w);
|
|
33
39
|
try {
|
|
34
|
-
const a = await
|
|
40
|
+
const a = await s.request(
|
|
35
41
|
h("/revisions/latest", { collection: t, items: o.join(",") })
|
|
36
42
|
);
|
|
37
|
-
for (const [
|
|
38
|
-
i.set(
|
|
43
|
+
for (const [u, c] of Object.entries((a == null ? void 0 : a.data) ?? {}))
|
|
44
|
+
i.set(u, typeof c == "number" && Number.isFinite(c) ? c : null);
|
|
39
45
|
} catch (a) {
|
|
40
46
|
if (!k(a)) continue;
|
|
41
|
-
let
|
|
42
|
-
const
|
|
47
|
+
let u = 0;
|
|
48
|
+
const c = async () => {
|
|
43
49
|
var g;
|
|
44
|
-
for (;
|
|
45
|
-
const y = o[
|
|
50
|
+
for (; u < o.length; ) {
|
|
51
|
+
const y = o[u++];
|
|
46
52
|
try {
|
|
47
|
-
const f = await
|
|
53
|
+
const f = await s.request(
|
|
48
54
|
h("/revisions", { collection: t, item: y, latest_only: "1" })
|
|
49
55
|
), l = (g = f == null ? void 0 : f.data) == null ? void 0 : g.latest;
|
|
50
56
|
i.set(y, typeof l == "number" && Number.isFinite(l) ? l : null);
|
|
@@ -52,41 +58,41 @@ async function S(r, t, n) {
|
|
|
52
58
|
}
|
|
53
59
|
}
|
|
54
60
|
};
|
|
55
|
-
await Promise.all(Array.from({ length: Math.min(4, o.length) },
|
|
61
|
+
await Promise.all(Array.from({ length: Math.min(4, o.length) }, c));
|
|
56
62
|
}
|
|
57
63
|
}
|
|
58
64
|
return i;
|
|
59
65
|
}
|
|
60
|
-
function
|
|
66
|
+
function L(s) {
|
|
61
67
|
try {
|
|
62
|
-
return JSON.stringify(
|
|
68
|
+
return JSON.stringify(s);
|
|
63
69
|
} catch {
|
|
64
70
|
return String(Math.random());
|
|
65
71
|
}
|
|
66
72
|
}
|
|
67
|
-
class
|
|
73
|
+
class M {
|
|
68
74
|
constructor(t) {
|
|
69
75
|
m(this, "entries", /* @__PURE__ */ new Map());
|
|
70
76
|
this.fetcher = t;
|
|
71
77
|
}
|
|
72
78
|
put(t, n, i) {
|
|
73
|
-
const
|
|
79
|
+
const r = {
|
|
74
80
|
sig: n,
|
|
75
81
|
base: i
|
|
76
82
|
};
|
|
77
|
-
this.entries.set(t,
|
|
78
|
-
|
|
83
|
+
this.entries.set(t, r), i.then((e) => {
|
|
84
|
+
r.settled = e;
|
|
79
85
|
});
|
|
80
86
|
}
|
|
81
87
|
/** Record a read of these rows. */
|
|
82
88
|
noteRows(t) {
|
|
83
|
-
var
|
|
89
|
+
var r;
|
|
84
90
|
const n = [];
|
|
85
91
|
for (const e of t) {
|
|
86
92
|
const o = (e == null ? void 0 : e.id) == null ? "" : String(e.id);
|
|
87
93
|
if (!o || o === "new" || o.startsWith("pending:")) continue;
|
|
88
|
-
const a =
|
|
89
|
-
((
|
|
94
|
+
const a = L(e);
|
|
95
|
+
((r = this.entries.get(o)) == null ? void 0 : r.sig) !== a && n.push({ id: o, sig: a });
|
|
90
96
|
}
|
|
91
97
|
if (n.length === 0) return;
|
|
92
98
|
const i = this.fetcher(n.map((e) => e.id)).catch(() => /* @__PURE__ */ new Map());
|
|
@@ -105,8 +111,8 @@ class R {
|
|
|
105
111
|
const e = await n.base;
|
|
106
112
|
if (e != null) return e;
|
|
107
113
|
}
|
|
108
|
-
const
|
|
109
|
-
return
|
|
114
|
+
const r = (await this.fetcher([t]).catch(() => /* @__PURE__ */ new Map())).get(t) ?? null;
|
|
115
|
+
return r != null && this.set(t, r), r;
|
|
110
116
|
}
|
|
111
117
|
/** The read-time base of a row, if a read noted it (undefined = never read). */
|
|
112
118
|
peek(t) {
|
|
@@ -121,8 +127,8 @@ class R {
|
|
|
121
127
|
/** After a 409: the person's next write is a choice made against `latest`. */
|
|
122
128
|
set(t, n) {
|
|
123
129
|
var e;
|
|
124
|
-
const
|
|
125
|
-
this.entries.set(t,
|
|
130
|
+
const r = { sig: ((e = this.entries.get(t)) == null ? void 0 : e.sig) ?? "", base: Promise.resolve(n), settled: n };
|
|
131
|
+
this.entries.set(t, r);
|
|
126
132
|
}
|
|
127
133
|
/** After the person's own write: the next read brings the new base. */
|
|
128
134
|
forget(t) {
|
|
@@ -130,72 +136,72 @@ class R {
|
|
|
130
136
|
}
|
|
131
137
|
}
|
|
132
138
|
const p = /* @__PURE__ */ new WeakMap();
|
|
133
|
-
function
|
|
134
|
-
let n = p.get(
|
|
135
|
-
n || (n = /* @__PURE__ */ new Map(), p.set(
|
|
139
|
+
function R(s, t) {
|
|
140
|
+
let n = p.get(s);
|
|
141
|
+
n || (n = /* @__PURE__ */ new Map(), p.set(s, n));
|
|
136
142
|
let i = n.get(t);
|
|
137
|
-
return i || (i = new
|
|
143
|
+
return i || (i = new M((r) => $(s, t, r)), n.set(t, i)), i;
|
|
138
144
|
}
|
|
139
|
-
async function j(
|
|
145
|
+
async function j(s, t, n, i, r, e) {
|
|
140
146
|
const o = await t.baseOf(i);
|
|
141
147
|
try {
|
|
142
|
-
await
|
|
148
|
+
await s.request(b(n, S(r, o)));
|
|
143
149
|
} catch (a) {
|
|
144
|
-
const
|
|
145
|
-
if (!
|
|
146
|
-
return
|
|
150
|
+
const u = d(a);
|
|
151
|
+
if (!u) throw a;
|
|
152
|
+
return u.latest > 0 && t.set(i, u.latest), {
|
|
147
153
|
ok: !1,
|
|
148
154
|
conflict: {
|
|
149
155
|
key: e.key,
|
|
150
156
|
rowId: i,
|
|
151
157
|
label: e.label,
|
|
152
|
-
conflicts:
|
|
153
|
-
latest:
|
|
154
|
-
mine:
|
|
158
|
+
conflicts: u.conflicts,
|
|
159
|
+
latest: u.latest,
|
|
160
|
+
mine: r,
|
|
155
161
|
url: n
|
|
156
162
|
}
|
|
157
163
|
};
|
|
158
164
|
}
|
|
159
165
|
return t.forget(i), { ok: !0 };
|
|
160
166
|
}
|
|
161
|
-
async function x(
|
|
167
|
+
async function x(s, t, n, i, r, e = 3) {
|
|
162
168
|
for (let o = 0; o < e; o++) {
|
|
163
|
-
const a = await
|
|
169
|
+
const a = await $(s, t, [n]), u = await s.request(
|
|
164
170
|
h(`/items/${t}/${n}`, { fields: `id,${i}` })
|
|
165
|
-
).then((
|
|
166
|
-
if (!
|
|
171
|
+
).then((c) => (c == null ? void 0 : c.data) ?? null);
|
|
172
|
+
if (!u) return !1;
|
|
167
173
|
try {
|
|
168
|
-
return await
|
|
174
|
+
return await s.request(
|
|
169
175
|
b(
|
|
170
176
|
`/items/${t}/${n}`,
|
|
171
|
-
|
|
177
|
+
S({ [i]: (Number(u[i]) || 0) + r }, a.get(n))
|
|
172
178
|
)
|
|
173
179
|
), !0;
|
|
174
|
-
} catch (
|
|
175
|
-
if (!d(
|
|
180
|
+
} catch (c) {
|
|
181
|
+
if (!d(c)) throw c;
|
|
176
182
|
}
|
|
177
183
|
}
|
|
178
184
|
return !1;
|
|
179
185
|
}
|
|
180
|
-
function F(
|
|
186
|
+
function F(s, t, n) {
|
|
181
187
|
const i = (e, o) => {
|
|
182
|
-
e[0] !== "o2m-rows" || String(e[3]) !== n || typeof e[1] != "string" || Array.isArray(o) &&
|
|
183
|
-
},
|
|
184
|
-
for (const e of
|
|
185
|
-
return
|
|
188
|
+
e[0] !== "o2m-rows" || String(e[3]) !== n || typeof e[1] != "string" || Array.isArray(o) && R(t, e[1]).noteRows(o);
|
|
189
|
+
}, r = s.getQueryCache();
|
|
190
|
+
for (const e of r.findAll({ queryKey: ["o2m-rows"] })) i(e.queryKey, e.state.data);
|
|
191
|
+
return r.subscribe((e) => {
|
|
186
192
|
e.type !== "updated" || e.action.type !== "success" || i(e.query.queryKey, e.query.state.data);
|
|
187
193
|
});
|
|
188
194
|
}
|
|
189
195
|
export {
|
|
190
196
|
w as LATEST_BATCH,
|
|
191
|
-
|
|
192
|
-
|
|
197
|
+
M as RowBaseBook,
|
|
198
|
+
$ as fetchLatestRevisions,
|
|
193
199
|
x as incrementGuarded,
|
|
194
200
|
B as lineConflictKey,
|
|
195
201
|
N as lineLabelOf,
|
|
196
202
|
F as noteLineReads,
|
|
197
203
|
C as resolveLineCollision,
|
|
198
|
-
|
|
199
|
-
|
|
204
|
+
R as rowBaseBookFor,
|
|
205
|
+
S as withRowBaseRevision,
|
|
200
206
|
j as writeLineGuarded
|
|
201
207
|
};
|