@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.
Files changed (29) hide show
  1. package/dist/hooks/useSessionRecorder.js +1 -1
  2. package/dist/index.d.ts +13 -3
  3. package/dist/shared/components/ItemEditForm.js +4801 -4666
  4. package/dist/shared/components/QueryTable.js +337 -324
  5. package/dist/shared/components/ReportView.js +105 -99
  6. package/dist/shared/components/alerts/AlertManagerView.js +327 -301
  7. package/dist/shared/components/item-edit/CatalogPickerField.js +1149 -1111
  8. package/dist/shared/components/item-edit/DraftRecoveryBanner.js +58 -53
  9. package/dist/shared/components/item-edit/FieldRenderer.js +227 -223
  10. package/dist/shared/components/item-edit/FieldRow.js +287 -265
  11. package/dist/shared/components/item-edit/FilePickerField.js +315 -307
  12. package/dist/shared/components/item-edit/InlineTableField.js +491 -466
  13. package/dist/shared/components/item-edit/RecordHeaderActions.js +76 -75
  14. package/dist/shared/components/item-edit/RecordLiveSync.js +93 -91
  15. package/dist/shared/components/item-edit/RelationCombobox.js +62 -60
  16. package/dist/shared/components/item-edit/SummaryPanel.js +287 -277
  17. package/dist/shared/components/item-edit/UserChip.js +233 -200
  18. package/dist/shared/components/item-edit/header-midair.js +51 -0
  19. package/dist/shared/components/item-edit/line-midair.js +76 -70
  20. package/dist/shared/components/panels/CommentPanel.js +290 -284
  21. package/dist/shared/components/panels/ItemLockBanner.js +30 -30
  22. package/dist/shared/components/panels/PipelinePanel.js +956 -901
  23. package/dist/shared/components/panels/TaskPanel.js +71 -61
  24. package/dist/shared/components/panels/TransitionRequirementsDialog.js +569 -439
  25. package/dist/shared/components/panels/requirement-side-effects.js +40 -0
  26. package/dist/shared/components/queue/QueueWorklist.js +141 -130
  27. package/dist/shared/lib/draft-store.js +48 -34
  28. package/dist/shared/lib/query-stats.js +60 -60
  29. 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 _ = Object.defineProperty;
2
- var $ = (r, t, n) => t in r ? _(r, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[t] = n;
3
- var m = (r, t, n) => $(r, typeof t != "symbol" ? t + "" : t, n);
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 q(r, t) {
7
- return typeof t != "number" || !Number.isFinite(t) || t <= 0 ? r : { ...r, _base_revision: t };
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(r, t) {
10
- return `${r.key}\0${r.rowId}\0${t}`;
9
+ function B(s, t) {
10
+ return `${s.key}\0${s.rowId}\0${t}`;
11
11
  }
12
- function C(r, t) {
12
+ function C(s, t) {
13
13
  const n = {};
14
- for (const [s, e] of Object.entries(r)) t.has(s) || (n[s] = e);
15
- return Object.keys(n).some((s) => s !== "_change_reason" && s !== "__flush_early") ? n : null;
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(r, t, n) {
18
- const i = r.findIndex((o) => String(o.id) === String(t)), s = i >= 0 ? r[i] : void 0, e = (s == null ? void 0 : s[n || "line_number"]) ?? (s == null ? void 0 : s.line_number);
19
- return e != null && e !== "" ? `Line ${String(e)}` : i >= 0 ? `Line ${i + 1}` : `Row ${t}`;
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(r) {
28
+ function k(s) {
23
29
  var n;
24
- const t = r;
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 S(r, t, n) {
28
- const i = /* @__PURE__ */ new Map(), s = [...new Set(n.map(String))].filter(
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 < s.length; e += w) {
32
- const o = s.slice(e, e + w);
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 r.request(
40
+ const a = await s.request(
35
41
  h("/revisions/latest", { collection: t, items: o.join(",") })
36
42
  );
37
- for (const [c, u] of Object.entries((a == null ? void 0 : a.data) ?? {}))
38
- i.set(c, typeof u == "number" && Number.isFinite(u) ? u : null);
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 c = 0;
42
- const u = async () => {
47
+ let u = 0;
48
+ const c = async () => {
43
49
  var g;
44
- for (; c < o.length; ) {
45
- const y = o[c++];
50
+ for (; u < o.length; ) {
51
+ const y = o[u++];
46
52
  try {
47
- const f = await r.request(
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) }, u));
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 M(r) {
66
+ function L(s) {
61
67
  try {
62
- return JSON.stringify(r);
68
+ return JSON.stringify(s);
63
69
  } catch {
64
70
  return String(Math.random());
65
71
  }
66
72
  }
67
- class R {
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 s = {
79
+ const r = {
74
80
  sig: n,
75
81
  base: i
76
82
  };
77
- this.entries.set(t, s), i.then((e) => {
78
- s.settled = e;
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 s;
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 = M(e);
89
- ((s = this.entries.get(o)) == null ? void 0 : s.sig) !== a && n.push({ id: o, sig: a });
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 s = (await this.fetcher([t]).catch(() => /* @__PURE__ */ new Map())).get(t) ?? null;
109
- return s != null && this.set(t, s), s;
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 s = { sig: ((e = this.entries.get(t)) == null ? void 0 : e.sig) ?? "", base: Promise.resolve(n), settled: n };
125
- this.entries.set(t, s);
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 L(r, t) {
134
- let n = p.get(r);
135
- n || (n = /* @__PURE__ */ new Map(), p.set(r, n));
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 R((s) => S(r, t, s)), n.set(t, i)), i;
143
+ return i || (i = new M((r) => $(s, t, r)), n.set(t, i)), i;
138
144
  }
139
- async function j(r, t, n, i, s, e) {
145
+ async function j(s, t, n, i, r, e) {
140
146
  const o = await t.baseOf(i);
141
147
  try {
142
- await r.request(b(n, q(s, o)));
148
+ await s.request(b(n, S(r, o)));
143
149
  } catch (a) {
144
- const c = d(a);
145
- if (!c) throw a;
146
- return c.latest > 0 && t.set(i, c.latest), {
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: c.conflicts,
153
- latest: c.latest,
154
- mine: s,
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(r, t, n, i, s, e = 3) {
167
+ async function x(s, t, n, i, r, e = 3) {
162
168
  for (let o = 0; o < e; o++) {
163
- const a = await S(r, t, [n]), c = await r.request(
169
+ const a = await $(s, t, [n]), u = await s.request(
164
170
  h(`/items/${t}/${n}`, { fields: `id,${i}` })
165
- ).then((u) => (u == null ? void 0 : u.data) ?? null);
166
- if (!c) return !1;
171
+ ).then((c) => (c == null ? void 0 : c.data) ?? null);
172
+ if (!u) return !1;
167
173
  try {
168
- return await r.request(
174
+ return await s.request(
169
175
  b(
170
176
  `/items/${t}/${n}`,
171
- q({ [i]: (Number(c[i]) || 0) + s }, a.get(n))
177
+ S({ [i]: (Number(u[i]) || 0) + r }, a.get(n))
172
178
  )
173
179
  ), !0;
174
- } catch (u) {
175
- if (!d(u)) throw u;
180
+ } catch (c) {
181
+ if (!d(c)) throw c;
176
182
  }
177
183
  }
178
184
  return !1;
179
185
  }
180
- function F(r, t, n) {
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) && L(t, e[1]).noteRows(o);
183
- }, s = r.getQueryCache();
184
- for (const e of s.findAll({ queryKey: ["o2m-rows"] })) i(e.queryKey, e.state.data);
185
- return s.subscribe((e) => {
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
- R as RowBaseBook,
192
- S as fetchLatestRevisions,
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
- L as rowBaseBookFor,
199
- q as withRowBaseRevision,
204
+ R as rowBaseBookFor,
205
+ S as withRowBaseRevision,
200
206
  j as writeLineGuarded
201
207
  };