@nivaro/react 0.3.12 → 0.3.14

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 (50) hide show
  1. package/dist/components/slots/pipeline/OwnersSection.js +79 -75
  2. package/dist/full.css +1 -1
  3. package/dist/hooks/useSessionRecorder.js +1 -1
  4. package/dist/index.d.ts +50 -2
  5. package/dist/index.js +601 -596
  6. package/dist/shared/components/CollectionBrowserView.js +2373 -2298
  7. package/dist/shared/components/DataTable.js +347 -335
  8. package/dist/shared/components/ItemEditForm.js +5278 -5149
  9. package/dist/shared/components/ListLoadError.js +33 -0
  10. package/dist/shared/components/PageRenderer.js +562 -529
  11. package/dist/shared/components/ProfileView.js +53 -51
  12. package/dist/shared/components/RecordReadView.js +119 -117
  13. package/dist/shared/components/ReportView.js +1268 -1241
  14. package/dist/shared/components/cbv/export-rows.js +69 -0
  15. package/dist/shared/components/cbv/saved-view-risk.js +35 -0
  16. package/dist/shared/components/cbv/unknown-fields.js +18 -0
  17. package/dist/shared/components/integrations/console/AlertsView.js +27 -25
  18. package/dist/shared/components/integrations/console/EventsView.js +244 -209
  19. package/dist/shared/components/item-edit/CatalogPickerField.js +946 -878
  20. package/dist/shared/components/item-edit/DraftRecoveryBanner.js +84 -57
  21. package/dist/shared/components/item-edit/FieldAffordances.js +63 -61
  22. package/dist/shared/components/item-edit/FieldRow.js +195 -179
  23. package/dist/shared/components/item-edit/FilePickerField.js +257 -254
  24. package/dist/shared/components/item-edit/HeaderTools.js +139 -95
  25. package/dist/shared/components/item-edit/InlineTableField.js +2087 -2075
  26. package/dist/shared/components/item-edit/RecordLiveSync.js +196 -181
  27. package/dist/shared/components/item-edit/RowComments.js +1 -3
  28. package/dist/shared/components/item-edit/SummaryPanel.js +62 -62
  29. package/dist/shared/components/item-edit/UserChip.js +113 -113
  30. package/dist/shared/components/item-edit/file-download.js +18 -0
  31. package/dist/shared/components/item-edit/line-qty.js +67 -32
  32. package/dist/shared/components/item-edit/save-refusal.js +23 -0
  33. package/dist/shared/components/monitoring/TrafficMiniMap.js +9 -9
  34. package/dist/shared/components/panels/CommentPanel.js +30 -30
  35. package/dist/shared/components/panels/ItemLockBanner.js +207 -185
  36. package/dist/shared/components/panels/PipelinePanel.js +915 -786
  37. package/dist/shared/components/pipeline/PipelineEditorView.js +45 -25
  38. package/dist/shared/components/profile/DelegationCard.js +1 -1
  39. package/dist/shared/components/profile/session-actions.js +24 -24
  40. package/dist/shared/components/queue/QueueItemSheet.js +18 -18
  41. package/dist/shared/components/queue/QueueWorklist.js +517 -504
  42. package/dist/shared/components/ui/dropdown-menu.js +8 -7
  43. package/dist/shared/context.js +71 -66
  44. package/dist/shared/lib/draft-store.js +60 -33
  45. package/dist/shared/lib/leave-guard.js +38 -0
  46. package/dist/shared/lib/load-error.js +38 -17
  47. package/dist/shared/lib/summary-mode.js +25 -25
  48. package/dist/shared/lib/table-pins.js +23 -0
  49. package/dist/shared/lib/validation-rules.js +55 -51
  50. package/package.json +1 -1
@@ -1,40 +1,40 @@
1
1
  import { jsxs as f, jsx as m } from "react/jsx-runtime";
2
- import { Lock as F, LockOpen as H } from "lucide-react";
3
- import { useState as g, useRef as Y, useCallback as x, useEffect as C } from "react";
2
+ import { Lock as V, LockOpen as ee } from "lucide-react";
3
+ import { useState as x, useRef as Y, useCallback as w, useEffect as S } from "react";
4
4
  import { toast as u } from "sonner";
5
- import { useNivaroClient as we, useItemEditAuth as _e } from "../../context.js";
6
- import { post as L, get as pe, del as B } from "../../lib/commands.js";
7
- import { idleState as $e } from "../../lib/idle.js";
8
- import { useOptionalRealtime as Ne } from "../../lib/realtime.js";
9
- import { announceRecordTabs as ee, useRecordTabsSignal as qe } from "../../lib/record-tabs.js";
10
- import { Button as O } from "../ui/button.js";
11
- import { Popover as te, PopoverTrigger as re, PopoverContent as ae } from "../ui/popover.js";
12
- const Se = 6e4, Le = 2 * 6e4;
13
- function Re() {
14
- const [t, r] = g(
5
+ import { useNivaroClient as pe, useItemEditAuth as $e } from "../../context.js";
6
+ import { post as R, get as Ne, del as D } from "../../lib/commands.js";
7
+ import { idleState as Se } from "../../lib/idle.js";
8
+ import { useOptionalRealtime as te, updateTouches as qe } from "../../lib/realtime.js";
9
+ import { announceRecordTabs as re, useRecordTabsSignal as Le } from "../../lib/record-tabs.js";
10
+ import { Button as I } from "../ui/button.js";
11
+ import { Popover as ae, PopoverTrigger as ne, PopoverContent as se } from "../ui/popover.js";
12
+ const Re = 6e4, Ce = 2 * 6e4, Ee = 3e4;
13
+ function Ae() {
14
+ const [t, r] = x(
15
15
  () => typeof document > "u" || document.visibilityState !== "hidden"
16
16
  );
17
- return C(() => {
17
+ return S(() => {
18
18
  const o = () => r(document.visibilityState !== "hidden");
19
19
  return document.addEventListener("visibilitychange", o), () => document.removeEventListener("visibilitychange", o);
20
20
  }, []), t;
21
21
  }
22
- function Me(t, r, o, R = {}) {
23
- const { lazy: q = !1, active: E = !0 } = R, n = we(), { isAdmin: N, userId: b } = _e(), [w, v] = g(null), [_, p] = g(!1), [D, A] = g(!1), [ne, se] = g([]), [oe, I] = g(null), [ie, Q] = g(!1), [le, V] = g(""), [ce, K] = g(!1), [ue, U] = g(!1), j = Y(null), i = Y(!1), S = Y(!1), M = Y(!1), z = Y(!1), P = Y(null), h = x(() => {
24
- j.current && (clearInterval(j.current), j.current = null);
25
- }, []), c = x(async () => {
26
- var s, a;
27
- if (!t || !r || z.current) return !1;
28
- P.current = null;
22
+ function Ke(t, r, o, C = {}) {
23
+ const { lazy: q = !1, active: E = !0 } = C, s = pe(), { isAdmin: N, userId: b } = $e(), [_, g] = x(null), [p, $] = x(!1), [M, A] = x(!1), [oe, ie] = x([]), [le, O] = x(null), [ce, U] = x(!1), [ue, W] = x(""), [de, F] = x(!1), [me, J] = x(!1), z = Y(null), i = Y(!1), L = Y(!1), P = Y(!1), j = Y(!1), K = Y(null), h = w(() => {
24
+ z.current && (clearInterval(z.current), z.current = null);
25
+ }, []), c = w(async () => {
26
+ var n, a;
27
+ if (!t || !r || j.current) return !1;
28
+ K.current = null;
29
29
  try {
30
- return await n.request(L(`/item-locks/${t}/${r}/lock`, {})), i.current = !0, p(!0), K(!1), v(null), h(), j.current = setInterval(() => {
30
+ return await s.request(R(`/item-locks/${t}/${r}/lock`, {})), i.current = !0, $(!0), F(!1), g(null), h(), z.current = setInterval(() => {
31
31
  const k = Math.max(
32
32
  0,
33
- Math.floor((Date.now() - new Date($e().last_active).getTime()) / 1e3)
33
+ Math.floor((Date.now() - new Date(Se().last_active).getTime()) / 1e3)
34
34
  );
35
- n.request(L(`/item-locks/${t}/${r}/heartbeat`, { idle_seconds: k })).then((l) => {
35
+ s.request(R(`/item-locks/${t}/${r}/heartbeat`, { idle_seconds: k })).then((l) => {
36
36
  if (!(l != null && l.idle_released)) return;
37
- h(), i.current = !1, p(!1), u.info(
37
+ h(), i.current = !1, $(!1), u.info(
38
38
  "Your edit lock was released after inactivity — it re-locks when you resume."
39
39
  );
40
40
  const e = () => {
@@ -45,35 +45,40 @@ function Me(t, r, o, R = {}) {
45
45
  var X, Z;
46
46
  const e = l, d = e.status ?? ((X = e.response) == null ? void 0 : X.status);
47
47
  if (d !== 404 && d !== 409) return;
48
- const y = ((Z = e.response) == null ? void 0 : Z.data) ?? e.response;
49
- if (d === 404 && !(y != null && y.locked_by)) {
48
+ const v = ((Z = e.response) == null ? void 0 : Z.data) ?? e.response;
49
+ if (d === 404 && !(v != null && v.locked_by)) {
50
50
  c();
51
51
  return;
52
52
  }
53
- h(), i.current = !1, p(!1), y != null && y.locked_by && (v({
54
- locked_by: y.locked_by,
55
- locked_by_name: y.locked_by_name ?? null
53
+ h(), i.current = !1, $(!1), v != null && v.locked_by && (g({
54
+ locked_by: v.locked_by,
55
+ locked_by_name: v.locked_by_name ?? null
56
56
  }), u.warning(
57
- `${y.locked_by_name ?? "Another user"} took over editing — your changes are no longer being saved`
57
+ `${v.locked_by_name ?? "Another user"} took over editing — your changes are no longer being saved`
58
58
  ));
59
59
  });
60
- }, Se), !0;
60
+ }, Re), !0;
61
61
  } catch (k) {
62
- const l = k, e = l.status ?? ((s = l.response) == null ? void 0 : s.status), d = ((a = l.response) == null ? void 0 : a.data) ?? l.response;
63
- return P.current = e ?? null, e === 404 ? (z.current = !0, h(), i.current = !1, p(!1), !1) : (e === 409 && (d != null && d.locked_by) && (i.current = !1, p(!1), v({
62
+ const l = k, e = l.status ?? ((n = l.response) == null ? void 0 : n.status), d = ((a = l.response) == null ? void 0 : a.data) ?? l.response;
63
+ return K.current = e ?? null, e === 404 ? (j.current = !0, h(), i.current = !1, $(!1), !1) : (e === 409 && (d != null && d.locked_by) && (i.current = !1, $(!1), g({
64
64
  locked_by: d.locked_by,
65
65
  locked_by_name: d.locked_by_name ?? null,
66
66
  ...typeof d.may_take_over == "boolean" ? { may_take_over: d.may_take_over } : {}
67
67
  })), !1);
68
68
  }
69
- }, [n, t, r, h]), $ = x(async () => {
69
+ }, [s, t, r, h]), y = w(async () => {
70
70
  if (!(!t || !r))
71
71
  try {
72
- const s = await n.request(pe(`/item-locks/${t}/${r}/lock`)), a = s == null ? void 0 : s.data;
73
- se(Array.isArray(a == null ? void 0 : a.queue) ? a.queue : []), I(typeof (a == null ? void 0 : a.my_position) == "number" ? a.my_position : null);
72
+ const n = await s.request(Ne(`/item-locks/${t}/${r}/lock`)), a = n == null ? void 0 : n.data;
73
+ ie(Array.isArray(a == null ? void 0 : a.queue) ? a.queue : []), O(typeof (a == null ? void 0 : a.my_position) == "number" ? a.my_position : null);
74
74
  const k = (a == null ? void 0 : a.is_mine) === !0 || !!b && String((a == null ? void 0 : a.locked_by) ?? "").toLowerCase() === b.toLowerCase(), l = typeof (a == null ? void 0 : a.may_take_over) == "boolean" ? { may_take_over: a.may_take_over } : {};
75
- a != null && a.locked_by && !i.current && !k && v(
76
- (e) => e ? {
75
+ if (i.current) return;
76
+ if (!(a != null && a.locked_by) || k) {
77
+ g(null);
78
+ return;
79
+ }
80
+ g(
81
+ (e) => e && e.locked_by === String(a.locked_by) ? {
77
82
  ...e,
78
83
  note: a.note ?? e.note ?? null,
79
84
  idle_minutes: a.locked_by_idle_minutes ?? e.idle_minutes ?? null,
@@ -82,51 +87,56 @@ function Me(t, r, o, R = {}) {
82
87
  locked_by: String(a.locked_by),
83
88
  locked_by_name: a.locked_by_name ?? null,
84
89
  note: a.note ?? null,
90
+ idle_minutes: a.locked_by_idle_minutes ?? null,
85
91
  ...l
86
92
  }
87
- );
88
- } catch (s) {
89
- (s == null ? void 0 : s.status) === 404 && (z.current = !0);
93
+ ), F(!1);
94
+ } catch (n) {
95
+ (n == null ? void 0 : n.status) === 404 && (j.current = !0);
90
96
  }
91
- }, [n, t, r, b]), W = (w == null ? void 0 : w.locked_by) ?? null;
92
- C(() => {
93
- W && $();
94
- }, [W, $]), C(() => {
97
+ }, [s, t, r, b]), B = (_ == null ? void 0 : _.locked_by) ?? null;
98
+ S(() => {
99
+ B && y();
100
+ }, [B, y]), S(() => {
101
+ if (!B) return;
102
+ const n = setInterval(() => void y(), Ee);
103
+ return () => clearInterval(n);
104
+ }, [B, y]), S(() => {
95
105
  if (!(!o || !t || !r))
96
- return S.current = !1, z.current = !1, q ? $() : c(), () => {
97
- h(), S.current = !1, i.current && (i.current = !1, n.request(B(`/item-locks/${t}/${r}/lock`)).then(() => ee(b, "lock-released", t, r)).catch(() => {
106
+ return L.current = !1, j.current = !1, q ? y() : c(), () => {
107
+ h(), L.current = !1, i.current && (i.current = !1, s.request(D(`/item-locks/${t}/${r}/lock`)).then(() => re(b, "lock-released", t, r)).catch(() => {
98
108
  }));
99
109
  };
100
- }, [o, t, r, c, n, h, b, q, $]);
101
- const de = x(async () => {
102
- if (!(!o || i.current || M.current)) {
103
- M.current = !0;
110
+ }, [o, t, r, c, s, h, b, q, y]);
111
+ const ke = w(async () => {
112
+ if (!(!o || i.current || P.current)) {
113
+ P.current = !0;
104
114
  try {
105
- !await c() && P.current === 409 && u.warning("Someone else is editing this record — your change can’t be saved yet");
115
+ !await c() && K.current === 409 && u.warning("Someone else is editing this record — your change can’t be saved yet");
106
116
  } finally {
107
- M.current = !1;
117
+ P.current = !1;
108
118
  }
109
119
  }
110
- }, [o, c]), me = Re(), J = E && me;
111
- C(() => {
120
+ }, [o, c]), he = Ae(), G = E && he;
121
+ S(() => {
112
122
  if (!o || !t || !r) return;
113
- if (J) {
114
- S.current && (S.current = !1, c());
123
+ if (G) {
124
+ L.current && (L.current = !1, c());
115
125
  return;
116
126
  }
117
- const s = setTimeout(() => {
118
- i.current && (h(), i.current = !1, p(!1), S.current = !0, n.request(B(`/item-locks/${t}/${r}/lock`)).then(() => ee(b, "lock-released", t, r)).catch(() => {
127
+ const n = setTimeout(() => {
128
+ i.current && (h(), i.current = !1, $(!1), L.current = !0, s.request(D(`/item-locks/${t}/${r}/lock`)).then(() => re(b, "lock-released", t, r)).catch(() => {
119
129
  }));
120
- }, Le);
121
- return () => clearTimeout(s);
122
- }, [o, J, t, r, c, n, h, b]), C(() => {
130
+ }, Ce);
131
+ return () => clearTimeout(n);
132
+ }, [o, G, t, r, c, s, h, b]), S(() => {
123
133
  if (!o || !t || !r) return;
124
- const s = () => {
134
+ const n = () => {
125
135
  var k;
126
136
  if (i.current) {
127
- h(), i.current = !1, S.current = !0;
137
+ h(), i.current = !1, L.current = !0;
128
138
  try {
129
- const l = (k = n.getToken) == null ? void 0 : k.call(n), e = n.url ?? "";
139
+ const l = (k = s.getToken) == null ? void 0 : k.call(s), e = s.url ?? "";
130
140
  fetch(
131
141
  `${e}/api/item-locks/${encodeURIComponent(t)}/${encodeURIComponent(r)}/lock/release`,
132
142
  {
@@ -141,29 +151,37 @@ function Me(t, r, o, R = {}) {
141
151
  }
142
152
  }
143
153
  }, a = (k) => {
144
- k.persisted && S.current && (S.current = !1, c());
154
+ k.persisted && L.current && (L.current = !1, c());
145
155
  };
146
- return window.addEventListener("pagehide", s), window.addEventListener("pageshow", a), () => {
147
- window.removeEventListener("pagehide", s), window.removeEventListener("pageshow", a);
156
+ return window.addEventListener("pagehide", n), window.addEventListener("pageshow", a), () => {
157
+ window.removeEventListener("pagehide", n), window.removeEventListener("pageshow", a);
148
158
  };
149
- }, [o, t, r, n, h, c]), qe(b, "lock-released", t, r, () => {
159
+ }, [o, t, r, s, h, c]), Le(b, "lock-released", t, r, () => {
150
160
  o && i.current && c();
151
161
  });
152
- const T = Ne(), [ke, G] = g(!1), he = x(async () => {
162
+ const Q = te();
163
+ S(() => {
164
+ if (!(!o || !Q || !t || !r))
165
+ return Q.subscribeCollections([t], (n) => {
166
+ var a;
167
+ i.current || j.current || !((a = n.changed_fields) != null && a.includes("$lock")) || !qe(n, r) || y();
168
+ });
169
+ }, [o, Q, t, r, y]);
170
+ const T = te(), [fe, H] = x(!1), be = w(async () => {
153
171
  if (!(!t || !r)) {
154
- G(!0);
172
+ H(!0);
155
173
  try {
156
- await n.request(L(`/item-locks/${t}/${r}/lock/request`, {})), u.success("Asked the current editor to release the lock");
174
+ await s.request(R(`/item-locks/${t}/${r}/lock/request`, {})), u.success("Asked the current editor to release the lock");
157
175
  } catch {
158
176
  u.error("Could not send the lock request");
159
177
  } finally {
160
- G(!1);
178
+ H(!1);
161
179
  }
162
180
  }
163
- }, [n, t, r]);
164
- C(() => {
181
+ }, [s, t, r]);
182
+ S(() => {
165
183
  if (!T || !t || !r) return;
166
- const s = T.on("lock:requested", (e) => {
184
+ const n = T.on("lock:requested", (e) => {
167
185
  if ((e == null ? void 0 : e.collection) !== t || String(e == null ? void 0 : e.item) !== String(r) || !i.current) return;
168
186
  const d = (e == null ? void 0 : e.from) ?? {};
169
187
  u(`${d.name ?? "Someone"} is asking you to release this record`, {
@@ -171,8 +189,8 @@ function Me(t, r, o, R = {}) {
171
189
  action: {
172
190
  label: "Release",
173
191
  onClick: () => {
174
- h(), i.current = !1, p(!1), n.request(
175
- L(`/item-locks/${t}/${r}/lock/respond`, {
192
+ h(), i.current = !1, $(!1), s.request(
193
+ R(`/item-locks/${t}/${r}/lock/respond`, {
176
194
  to: d.id,
177
195
  action: "release"
178
196
  })
@@ -182,8 +200,8 @@ function Me(t, r, o, R = {}) {
182
200
  cancel: {
183
201
  label: "Keep editing",
184
202
  onClick: () => {
185
- n.request(
186
- L(`/item-locks/${t}/${r}/lock/respond`, {
203
+ s.request(
204
+ R(`/item-locks/${t}/${r}/lock/respond`, {
187
205
  to: d.id,
188
206
  action: "decline"
189
207
  })
@@ -193,120 +211,124 @@ function Me(t, r, o, R = {}) {
193
211
  }
194
212
  });
195
213
  }), a = T.on("lock:response", (e) => {
196
- var d, y;
214
+ var d, v;
197
215
  (e == null ? void 0 : e.collection) !== t || String(e == null ? void 0 : e.item) !== String(r) || i.current || ((e == null ? void 0 : e.action) === "release" ? (u.success(`${((d = e == null ? void 0 : e.from) == null ? void 0 : d.name) ?? "The editor"} released the lock — it's yours`), c()) : u.warning(
198
- `${((y = e == null ? void 0 : e.from) == null ? void 0 : y.name) ?? "The editor"} is keeping the lock${e != null && e.note ? `: "${e.note}"` : ""}`
216
+ `${((v = e == null ? void 0 : e.from) == null ? void 0 : v.name) ?? "The editor"} is keeping the lock${e != null && e.note ? `: "${e.note}"` : ""}`
199
217
  ));
200
218
  }), k = T.on("lock:available", (e) => {
201
- (e == null ? void 0 : e.collection) !== t || String(e == null ? void 0 : e.item) !== String(r) || i.current || (u.success("Your turn — the edit lock is yours"), I(null), c());
219
+ (e == null ? void 0 : e.collection) !== t || String(e == null ? void 0 : e.item) !== String(r) || i.current || (u.success("Your turn — the edit lock is yours"), O(null), c());
202
220
  }), l = T.on("lock:queued", (e) => {
203
- (e == null ? void 0 : e.collection) !== t || String(e == null ? void 0 : e.item) !== String(r) || (i.current && u(`${(e == null ? void 0 : e.user_name) ?? "Someone"} is waiting to edit this record`, { duration: 8e3 }), $());
221
+ (e == null ? void 0 : e.collection) !== t || String(e == null ? void 0 : e.item) !== String(r) || (i.current && u(`${(e == null ? void 0 : e.user_name) ?? "Someone"} is waiting to edit this record`, { duration: 8e3 }), y());
204
222
  });
205
223
  return () => {
206
- s(), a(), k(), l();
224
+ n(), a(), k(), l();
207
225
  };
208
- }, [T, t, r, n, c, h, $]);
209
- const fe = x(async () => {
210
- var s;
226
+ }, [T, t, r, s, c, h, y]);
227
+ const ye = w(async () => {
211
228
  if (!(!t || !r)) {
212
- Q(!0);
229
+ U(!0);
213
230
  try {
214
- const a = await n.request(
215
- L(`/item-locks/${t}/${r}/lock/queue`, {})
216
- ), k = (s = a == null ? void 0 : a.data) == null ? void 0 : s.position;
217
- I(typeof k == "number" ? k : 1), u.success("You are in line — the lock comes to you automatically when it frees up"), $();
231
+ const n = await s.request(
232
+ R(`/item-locks/${t}/${r}/lock/queue`, {})
233
+ ), a = n == null ? void 0 : n.data;
234
+ if (a != null && a.free) {
235
+ O(null), g(null), u.success("Nobody is editing this record now — go ahead");
236
+ return;
237
+ }
238
+ const k = a == null ? void 0 : a.position;
239
+ O(typeof k == "number" ? k : 1), u.success("You are in line — the lock comes to you automatically when it frees up"), y();
218
240
  } catch {
219
241
  u.error("Could not join the queue");
220
242
  } finally {
221
- Q(!1);
243
+ U(!1);
222
244
  }
223
245
  }
224
- }, [n, t, r, $]), be = x(async () => {
246
+ }, [s, t, r, y]), ge = w(async () => {
225
247
  if (!(!t || !r))
226
248
  try {
227
- await n.request(B(`/item-locks/${t}/${r}/lock/queue`)), I(null), $();
249
+ await s.request(D(`/item-locks/${t}/${r}/lock/queue`)), O(null), y();
228
250
  } catch {
229
251
  }
230
- }, [n, t, r, $]), ye = x(
231
- async (s) => {
252
+ }, [s, t, r, y]), ve = w(
253
+ async (n) => {
232
254
  if (!(!t || !r || !i.current)) {
233
- V(s);
255
+ W(n);
234
256
  try {
235
- await n.request(L(`/item-locks/${t}/${r}/lock/note`, { note: s }));
257
+ await s.request(R(`/item-locks/${t}/${r}/lock/note`, { note: n }));
236
258
  } catch {
237
259
  }
238
260
  }
239
261
  },
240
- [n, t, r]
241
- ), ge = x(async () => {
262
+ [s, t, r]
263
+ ), xe = w(async () => {
242
264
  if (!(!t || !r || !i.current)) {
243
- U(!0), h(), i.current = !1, p(!1);
265
+ J(!0), h(), i.current = !1, $(!1);
244
266
  try {
245
- await n.request(B(`/item-locks/${t}/${r}/lock`)), K(!0), V(""), u.success("Lock released — anyone can edit this record now");
267
+ await s.request(D(`/item-locks/${t}/${r}/lock`)), F(!0), W(""), u.success("Lock released — anyone can edit this record now");
246
268
  } catch {
247
269
  u.error("Failed to release the lock"), c();
248
270
  } finally {
249
- U(!1);
271
+ J(!1);
250
272
  }
251
273
  }
252
- }, [n, t, r, h, c]), ve = x(async () => {
274
+ }, [s, t, r, h, c]), we = w(async () => {
253
275
  if (i.current) return !0;
254
- const s = await c();
255
- return s && u.success("You hold the edit lock again"), s;
256
- }, [c]), xe = x(async () => {
257
- var s;
276
+ const n = await c();
277
+ return n && u.success("You hold the edit lock again"), n;
278
+ }, [c]), _e = w(async () => {
279
+ var n;
258
280
  if (!(!t || !r)) {
259
281
  A(!0);
260
282
  try {
261
- await n.request(L(`/item-locks/${t}/${r}/lock/force`, {})), u.success("You now hold the edit lock"), await c();
283
+ await s.request(R(`/item-locks/${t}/${r}/lock/force`, {})), u.success("You now hold the edit lock"), await c();
262
284
  } catch (a) {
263
- const k = ((s = a == null ? void 0 : a.response) == null ? void 0 : s.error) ?? "Failed to take over the lock";
264
- u.error(k), (a == null ? void 0 : a.status) === 403 && v((l) => l && { ...l, may_take_over: !1 });
285
+ const k = ((n = a == null ? void 0 : a.response) == null ? void 0 : n.error) ?? "Failed to take over the lock";
286
+ u.error(k), (a == null ? void 0 : a.status) === 403 && g((l) => l && { ...l, may_take_over: !1 });
265
287
  } finally {
266
288
  A(!1);
267
289
  }
268
290
  }
269
- }, [n, t, r, c]);
291
+ }, [s, t, r, c]);
270
292
  return {
271
- lockHolder: w,
272
- acquired: _,
273
- isReadOnly: !!w,
274
- takeOver: xe,
275
- takingOver: D,
293
+ lockHolder: _,
294
+ acquired: p,
295
+ isReadOnly: !!_,
296
+ takeOver: _e,
297
+ takingOver: M,
276
298
  isAdmin: N,
277
- requestLock: he,
278
- requesting: ke,
279
- queue: ne,
280
- myPosition: oe,
281
- joinQueue: fe,
282
- leaveQueue: be,
283
- joining: ie,
284
- myNote: le,
285
- saveNote: ye,
286
- release: ge,
287
- releasing: ue,
288
- released: ce,
289
- relock: ve,
290
- claim: de
299
+ requestLock: be,
300
+ requesting: fe,
301
+ queue: oe,
302
+ myPosition: le,
303
+ joinQueue: ye,
304
+ leaveQueue: ge,
305
+ joining: ce,
306
+ myNote: ue,
307
+ saveNote: ve,
308
+ release: xe,
309
+ releasing: me,
310
+ released: de,
311
+ relock: we,
312
+ claim: ke
291
313
  };
292
314
  }
293
- function Pe({
315
+ function Qe({
294
316
  note: t,
295
317
  onSave: r,
296
318
  waiting: o,
297
- onRelease: R,
319
+ onRelease: C,
298
320
  releasing: q,
299
321
  released: E,
300
- onRelock: n
322
+ onRelock: s
301
323
  }) {
302
- var v;
303
- const [N, b] = g(t);
304
- C(() => b(t), [t]);
305
- const w = () => {
324
+ var g;
325
+ const [N, b] = x(t);
326
+ S(() => b(t), [t]);
327
+ const _ = () => {
306
328
  N.trim() !== t && r(N.trim());
307
329
  };
308
- return E ? /* @__PURE__ */ f(te, { children: [
309
- /* @__PURE__ */ m(re, { asChild: !0, children: /* @__PURE__ */ m(
330
+ return E ? /* @__PURE__ */ f(ae, { children: [
331
+ /* @__PURE__ */ m(ne, { asChild: !0, children: /* @__PURE__ */ m(
310
332
  "button",
311
333
  {
312
334
  type: "button",
@@ -314,29 +336,29 @@ function Pe({
314
336
  title: "Lock released — anyone can edit this record",
315
337
  "data-lock-released": !0,
316
338
  className: "relative inline-flex h-8 w-8 items-center justify-center text-slate-400 transition-colors hover:bg-accent hover:text-accent-foreground dark:text-slate-500",
317
- children: /* @__PURE__ */ m(H, { className: "h-4 w-4", strokeWidth: 2 })
339
+ children: /* @__PURE__ */ m(ee, { className: "h-4 w-4", strokeWidth: 2 })
318
340
  }
319
341
  ) }),
320
- /* @__PURE__ */ f(ae, { align: "end", sideOffset: 6, className: "w-[300px] p-3", children: [
342
+ /* @__PURE__ */ f(se, { align: "end", sideOffset: 6, className: "w-[300px] p-3", children: [
321
343
  /* @__PURE__ */ m("p", { className: "text-[12px] font-semibold text-slate-700 dark:text-slate-200", children: "You released the edit lock" }),
322
344
  /* @__PURE__ */ m("p", { className: "mt-0.5 text-[11px] text-slate-500 dark:text-slate-400", children: "Anyone can edit this record now. Your next edit locks it again — or lock it now." }),
323
345
  /* @__PURE__ */ f(
324
- O,
346
+ I,
325
347
  {
326
348
  type: "button",
327
349
  size: "sm",
328
350
  className: "mt-2 h-7 w-full text-[12px]",
329
- onClick: n,
351
+ onClick: s,
330
352
  "data-lock-relock": !0,
331
353
  children: [
332
- /* @__PURE__ */ m(F, { className: "mr-1.5 h-3.5 w-3.5" }),
354
+ /* @__PURE__ */ m(V, { className: "mr-1.5 h-3.5 w-3.5" }),
333
355
  " Lock again"
334
356
  ]
335
357
  }
336
358
  )
337
359
  ] })
338
- ] }) : /* @__PURE__ */ f(te, { children: [
339
- /* @__PURE__ */ m(re, { asChild: !0, children: /* @__PURE__ */ f(
360
+ ] }) : /* @__PURE__ */ f(ae, { children: [
361
+ /* @__PURE__ */ m(ne, { asChild: !0, children: /* @__PURE__ */ f(
340
362
  "button",
341
363
  {
342
364
  type: "button",
@@ -345,22 +367,22 @@ function Pe({
345
367
  "data-lock-holder": !0,
346
368
  className: "relative inline-flex h-8 w-8 items-center justify-center text-[#0e7490] transition-colors hover:bg-accent hover:text-accent-foreground dark:text-nvr-cyan",
347
369
  children: [
348
- /* @__PURE__ */ m(F, { className: "h-4 w-4", strokeWidth: 2 }),
370
+ /* @__PURE__ */ m(V, { className: "h-4 w-4", strokeWidth: 2 }),
349
371
  o.length > 0 && /* @__PURE__ */ m("span", { className: "absolute right-1 top-1 h-1.5 w-1.5 rounded-full bg-amber-500 ring-2 ring-background" })
350
372
  ]
351
373
  }
352
374
  ) }),
353
- /* @__PURE__ */ f(ae, { align: "end", sideOffset: 6, className: "w-[300px] p-3", children: [
375
+ /* @__PURE__ */ f(se, { align: "end", sideOffset: 6, className: "w-[300px] p-3", children: [
354
376
  /* @__PURE__ */ m("p", { className: "text-[12px] font-semibold text-slate-700 dark:text-slate-200", children: "You hold the edit lock" }),
355
377
  /* @__PURE__ */ m("p", { className: "mt-0.5 text-[11px] text-slate-500 dark:text-slate-400", children: "Others see this record read-only. A note tells them what you’re doing." }),
356
378
  /* @__PURE__ */ m(
357
379
  "input",
358
380
  {
359
381
  value: N,
360
- onChange: (_) => b(_.target.value.slice(0, 300)),
361
- onBlur: w,
362
- onKeyDown: (_) => {
363
- _.key === "Enter" && (_.preventDefault(), w());
382
+ onChange: (p) => b(p.target.value.slice(0, 300)),
383
+ onBlur: _,
384
+ onKeyDown: (p) => {
385
+ p.key === "Enter" && (p.preventDefault(), _());
364
386
  },
365
387
  placeholder: "“editing lines, ~15 min”",
366
388
  "aria-label": "Lock note",
@@ -373,57 +395,57 @@ function Pe({
373
395
  " waiting for the lock:"
374
396
  ] }),
375
397
  " ",
376
- o.map((_) => _.name ?? "someone").join(", ")
398
+ o.map((p) => p.name ?? "someone").join(", ")
377
399
  ] }),
378
- R && /* @__PURE__ */ f(
379
- O,
400
+ C && /* @__PURE__ */ f(
401
+ I,
380
402
  {
381
403
  type: "button",
382
404
  variant: "outline",
383
405
  size: "sm",
384
406
  className: "mt-2 h-7 w-full text-[12px]",
385
- onClick: R,
407
+ onClick: C,
386
408
  disabled: q,
387
409
  "data-lock-release": !0,
388
410
  children: [
389
- /* @__PURE__ */ m(H, { className: "mr-1.5 h-3.5 w-3.5" }),
390
- q ? "Releasing…" : o.length > 0 ? `Release lock to ${((v = o[0]) == null ? void 0 : v.name) ?? "the next person"}` : "Release lock"
411
+ /* @__PURE__ */ m(ee, { className: "mr-1.5 h-3.5 w-3.5" }),
412
+ q ? "Releasing…" : o.length > 0 ? `Release lock to ${((g = o[0]) == null ? void 0 : g.name) ?? "the next person"}` : "Release lock"
391
413
  ]
392
414
  }
393
415
  )
394
416
  ] })
395
417
  ] });
396
418
  }
397
- function Fe({
419
+ function Ve({
398
420
  lockHolder: t,
399
421
  onTakeOver: r,
400
422
  takingOver: o,
401
- isAdmin: R,
423
+ isAdmin: C,
402
424
  onRequestLock: q,
403
425
  requesting: E,
404
- queue: n,
426
+ queue: s,
405
427
  myPosition: N,
406
428
  onJoinQueue: b,
407
- onLeaveQueue: w,
408
- joining: v,
409
- noun: _ = "this item",
410
- readOnlyText: p = "fields are read-only"
429
+ onLeaveQueue: _,
430
+ joining: g,
431
+ noun: p = "this item",
432
+ readOnlyText: $ = "fields are read-only"
411
433
  }) {
412
434
  if (!t) return null;
413
- const D = t.locked_by_name || "Another user", A = (n == null ? void 0 : n.length) ?? 0;
435
+ const M = t.locked_by_name || "Another user", A = (s == null ? void 0 : s.length) ?? 0;
414
436
  return /* @__PURE__ */ f(
415
437
  "div",
416
438
  {
417
439
  className: "mb-4 flex flex-wrap items-center gap-3 rounded-lg border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-900 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-100",
418
440
  "data-lock-banner": !0,
419
441
  children: [
420
- /* @__PURE__ */ m(F, { className: "h-4 w-4 shrink-0 text-amber-500" }),
442
+ /* @__PURE__ */ m(V, { className: "h-4 w-4 shrink-0 text-amber-500" }),
421
443
  /* @__PURE__ */ f("span", { className: "min-w-0 flex-1", children: [
422
- /* @__PURE__ */ m("span", { className: "font-medium", children: D }),
444
+ /* @__PURE__ */ m("span", { className: "font-medium", children: M }),
423
445
  " is editing ",
424
- _,
425
- " — ",
426
446
  p,
447
+ " — ",
448
+ $,
427
449
  t.idle_minutes != null && t.idle_minutes >= 2 && /* @__PURE__ */ f(
428
450
  "span",
429
451
  {
@@ -452,12 +474,12 @@ function Fe({
452
474
  ] })
453
475
  ] }),
454
476
  b && (N != null ? /* @__PURE__ */ f(
455
- O,
477
+ I,
456
478
  {
457
479
  size: "sm",
458
480
  variant: "outline",
459
481
  className: "h-7 shrink-0 border-amber-300 bg-white text-[12px] text-amber-800 hover:bg-amber-100 dark:border-amber-500/40 dark:bg-transparent dark:text-amber-200 dark:hover:bg-amber-500/15",
460
- onClick: w,
482
+ onClick: _,
461
483
  "data-lock-queue-leave": !0,
462
484
  children: [
463
485
  "You’re #",
@@ -466,19 +488,19 @@ function Fe({
466
488
  ]
467
489
  }
468
490
  ) : /* @__PURE__ */ m(
469
- O,
491
+ I,
470
492
  {
471
493
  size: "sm",
472
494
  variant: "outline",
473
495
  className: "h-7 shrink-0 border-amber-300 bg-white text-[12px] text-amber-800 hover:bg-amber-100 dark:border-amber-500/40 dark:bg-transparent dark:text-amber-200 dark:hover:bg-amber-500/15",
474
496
  onClick: b,
475
- disabled: v,
497
+ disabled: g,
476
498
  "data-lock-queue-join": !0,
477
- children: v ? "Joining…" : "Ask to be next"
499
+ children: g ? "Joining…" : "Ask to be next"
478
500
  }
479
501
  )),
480
502
  q && /* @__PURE__ */ m(
481
- O,
503
+ I,
482
504
  {
483
505
  size: "sm",
484
506
  variant: "outline",
@@ -491,12 +513,12 @@ function Fe({
491
513
  // Admins always; other roles only when the server says they may (the
492
514
  // takeover-role allowlist, #256) — unknown = offered, and a 403 then
493
515
  // hides it. A Take over that can only fail was a dead end.
494
- (R || t.may_take_over !== !1) && /* @__PURE__ */ m(
495
- O,
516
+ (C || t.may_take_over !== !1) && /* @__PURE__ */ m(
517
+ I,
496
518
  {
497
519
  size: "sm",
498
520
  variant: "outline",
499
- className: R ? "h-7 shrink-0 border-amber-300 bg-white text-[12px] text-amber-800 hover:bg-amber-100 dark:border-amber-500/40 dark:bg-transparent dark:text-amber-200 dark:hover:bg-amber-500/15" : "h-7 shrink-0 border-amber-200 bg-white/60 text-[12px] text-amber-700/80 hover:bg-amber-100 dark:border-amber-500/30 dark:bg-transparent dark:text-amber-200/80 dark:hover:bg-amber-500/15",
521
+ className: C ? "h-7 shrink-0 border-amber-300 bg-white text-[12px] text-amber-800 hover:bg-amber-100 dark:border-amber-500/40 dark:bg-transparent dark:text-amber-200 dark:hover:bg-amber-500/15" : "h-7 shrink-0 border-amber-200 bg-white/60 text-[12px] text-amber-700/80 hover:bg-amber-100 dark:border-amber-500/30 dark:bg-transparent dark:text-amber-200/80 dark:hover:bg-amber-500/15",
500
522
  onClick: r,
501
523
  disabled: o,
502
524
  children: o ? "Taking over…" : "Take over"
@@ -507,7 +529,7 @@ function Fe({
507
529
  );
508
530
  }
509
531
  export {
510
- Fe as ItemLockBanner,
511
- Pe as LockHolderButton,
512
- Me as useItemLock
532
+ Ve as ItemLockBanner,
533
+ Qe as LockHolderButton,
534
+ Ke as useItemLock
513
535
  };