@nivaro/react 0.3.9 → 0.3.11
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/components/fields/FileField.js +20 -19
- package/dist/full.css +1 -1
- package/dist/hooks/useNivaroForm.js +129 -126
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +103 -4
- package/dist/index.js +512 -501
- package/dist/shared/components/CollectionBrowserView.js +1632 -1564
- package/dist/shared/components/ConformanceView.js +36 -35
- package/dist/shared/components/ForceReloadBanner.js +58 -34
- package/dist/shared/components/ItemEditForm.js +4386 -4142
- package/dist/shared/components/JsonMapEditor.js +18 -17
- package/dist/shared/components/MatrixEditor.js +8 -7
- package/dist/shared/components/MyWorkView.js +32 -31
- package/dist/shared/components/PageRenderer.js +527 -479
- package/dist/shared/components/QueryStatStrip.js +74 -70
- package/dist/shared/components/RecordGridEditor.js +76 -75
- package/dist/shared/components/ReportView.js +818 -827
- package/dist/shared/components/SheetHeaderBody.js +16 -14
- package/dist/shared/components/ai/AiMemorySuggestions.js +15 -14
- package/dist/shared/components/ai/AskPanel.js +55 -54
- package/dist/shared/components/bulk/BulkActionButtons.js +30 -29
- package/dist/shared/components/bulk/PushBulkButtons.js +57 -56
- package/dist/shared/components/chat/SlashCommands.js +30 -29
- package/dist/shared/components/chat/chat-outbox.js +76 -75
- package/dist/shared/components/help-videos/recorder/useLeaveWarning.js +6 -5
- package/dist/shared/components/integrations/console/SignalCard.js +124 -123
- package/dist/shared/components/integrations/console/SnoozeMenu.js +24 -23
- package/dist/shared/components/item-edit/CatalogPickerField.js +1029 -933
- package/dist/shared/components/item-edit/CloneDialog.js +85 -78
- 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 +2287 -2275
- package/dist/shared/components/item-edit/M2MCombobox.js +46 -44
- package/dist/shared/components/item-edit/MembershipSetField.js +24 -23
- package/dist/shared/components/item-edit/NestedRelationEditor.js +11 -11
- package/dist/shared/components/item-edit/QuickCreateButton.js +8 -7
- package/dist/shared/components/item-edit/QuickPicker.js +263 -216
- package/dist/shared/components/item-edit/RecordLiveSync.js +101 -100
- 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/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/item-edit/staged-links.js +86 -0
- package/dist/shared/components/layout-editor/LayoutEditor.js +275 -274
- package/dist/shared/components/layout-editor/editors/cascade-rule-row.js +18 -17
- package/dist/shared/components/layout-editor/inspector/HelpTab.js +37 -36
- package/dist/shared/components/layout-editor/matrix/FieldStateMatrix.js +50 -49
- 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/AiMemoryCard.js +15 -14
- package/dist/shared/components/profile/PersonAdminTools.js +70 -67
- package/dist/shared/components/queue/QueueItemSheet.js +36 -35
- package/dist/shared/components/queue/QueueQuickFilters.js +43 -41
- package/dist/shared/components/queue/QueueWorklist.js +1026 -957
- package/dist/shared/components/widgets/ReviewListWidget.js +99 -93
- package/dist/shared/lib/client-version.js +63 -0
- package/dist/shared/lib/force-reload.js +36 -0
- package/dist/shared/lib/load-error.js +11 -10
- package/dist/shared/lib/obligation-banner.js +14 -13
- package/dist/shared/lib/obligation-reason-text.js +13 -0
- package/dist/shared/lib/presence-live.js +54 -35
- package/dist/shared/lib/query-filter-seed.js +34 -11
- package/dist/shared/lib/record-outbox.js +76 -75
- package/dist/shared/lib/safe-error.js +39 -0
- package/dist/shared/lib/sanitize-html.js +24 -15
- package/dist/shared/lib/server-clock.js +11 -7
- package/dist/shared/lib/sheet-def.js +38 -22
- package/dist/shared/lib/unique-options.js +10 -0
- package/dist/shared/lib/unsaved-work.js +62 -0
- package/dist/shared/lib/utils.js +57 -43
- package/dist/shared/lib/validation-rules.js +58 -34
- package/package.json +1 -1
|
@@ -1,125 +1,190 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { Lock as
|
|
3
|
-
import { useState as
|
|
4
|
-
import { toast as
|
|
5
|
-
import { useNivaroClient as
|
|
6
|
-
import { post as
|
|
7
|
-
import { idleState as
|
|
8
|
-
import { useOptionalRealtime as
|
|
9
|
-
import { announceRecordTabs as
|
|
10
|
-
import { Button as
|
|
11
|
-
import { Popover as
|
|
12
|
-
const
|
|
13
|
-
function
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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";
|
|
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(
|
|
15
|
+
() => typeof document > "u" || document.visibilityState !== "hidden"
|
|
16
|
+
);
|
|
17
|
+
return C(() => {
|
|
18
|
+
const o = () => r(document.visibilityState !== "hidden");
|
|
19
|
+
return document.addEventListener("visibilitychange", o), () => document.removeEventListener("visibilitychange", o);
|
|
20
|
+
}, []), t;
|
|
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;
|
|
19
29
|
try {
|
|
20
|
-
return await
|
|
21
|
-
const
|
|
30
|
+
return await n.request(L(`/item-locks/${t}/${r}/lock`, {})), i.current = !0, p(!0), K(!1), v(null), h(), j.current = setInterval(() => {
|
|
31
|
+
const k = Math.max(
|
|
22
32
|
0,
|
|
23
|
-
Math.floor((Date.now() - new Date(
|
|
33
|
+
Math.floor((Date.now() - new Date($e().last_active).getTime()) / 1e3)
|
|
24
34
|
);
|
|
25
|
-
|
|
26
|
-
if (!(
|
|
27
|
-
|
|
35
|
+
n.request(L(`/item-locks/${t}/${r}/heartbeat`, { idle_seconds: k })).then((l) => {
|
|
36
|
+
if (!(l != null && l.idle_released)) return;
|
|
37
|
+
h(), i.current = !1, p(!1), u.info(
|
|
28
38
|
"Your edit lock was released after inactivity — it re-locks when you resume."
|
|
29
39
|
);
|
|
30
40
|
const e = () => {
|
|
31
|
-
window.removeEventListener("pointerdown", e, !0), window.removeEventListener("keydown", e, !0),
|
|
41
|
+
window.removeEventListener("pointerdown", e, !0), window.removeEventListener("keydown", e, !0), c();
|
|
32
42
|
};
|
|
33
43
|
window.addEventListener("pointerdown", e, !0), window.addEventListener("keydown", e, !0);
|
|
34
|
-
}).catch((
|
|
35
|
-
var
|
|
36
|
-
const e =
|
|
37
|
-
if (
|
|
38
|
-
const
|
|
39
|
-
if (
|
|
40
|
-
|
|
44
|
+
}).catch((l) => {
|
|
45
|
+
var X, Z;
|
|
46
|
+
const e = l, d = e.status ?? ((X = e.response) == null ? void 0 : X.status);
|
|
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)) {
|
|
50
|
+
c();
|
|
41
51
|
return;
|
|
42
52
|
}
|
|
43
|
-
|
|
44
|
-
locked_by:
|
|
45
|
-
locked_by_name:
|
|
46
|
-
}),
|
|
47
|
-
`${
|
|
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
|
|
56
|
+
}), u.warning(
|
|
57
|
+
`${y.locked_by_name ?? "Another user"} took over editing — your changes are no longer being saved`
|
|
48
58
|
));
|
|
49
59
|
});
|
|
50
|
-
},
|
|
51
|
-
} catch (
|
|
52
|
-
const
|
|
53
|
-
return e === 409 && (
|
|
54
|
-
locked_by:
|
|
55
|
-
locked_by_name:
|
|
56
|
-
|
|
60
|
+
}, Se), !0;
|
|
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({
|
|
64
|
+
locked_by: d.locked_by,
|
|
65
|
+
locked_by_name: d.locked_by_name ?? null,
|
|
66
|
+
...typeof d.may_take_over == "boolean" ? { may_take_over: d.may_take_over } : {}
|
|
67
|
+
})), !1);
|
|
57
68
|
}
|
|
58
|
-
}, [
|
|
69
|
+
}, [n, t, r, h]), $ = x(async () => {
|
|
59
70
|
if (!(!t || !r))
|
|
60
71
|
try {
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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);
|
|
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 ? {
|
|
77
|
+
...e,
|
|
78
|
+
note: a.note ?? e.note ?? null,
|
|
79
|
+
idle_minutes: a.locked_by_idle_minutes ?? e.idle_minutes ?? null,
|
|
80
|
+
...l
|
|
67
81
|
} : {
|
|
68
82
|
locked_by: String(a.locked_by),
|
|
69
83
|
locked_by_name: a.locked_by_name ?? null,
|
|
70
|
-
note: a.note ?? null
|
|
84
|
+
note: a.note ?? null,
|
|
85
|
+
...l
|
|
71
86
|
}
|
|
72
87
|
);
|
|
73
|
-
} catch {
|
|
88
|
+
} catch (s) {
|
|
89
|
+
(s == null ? void 0 : s.status) === 404 && (z.current = !0);
|
|
74
90
|
}
|
|
75
|
-
}, [
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}, [
|
|
79
|
-
if (!(!
|
|
80
|
-
return
|
|
81
|
-
|
|
91
|
+
}, [n, t, r, b]), W = (w == null ? void 0 : w.locked_by) ?? null;
|
|
92
|
+
C(() => {
|
|
93
|
+
W && $();
|
|
94
|
+
}, [W, $]), C(() => {
|
|
95
|
+
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(() => {
|
|
82
98
|
}));
|
|
83
99
|
};
|
|
84
|
-
}, [
|
|
85
|
-
|
|
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;
|
|
104
|
+
try {
|
|
105
|
+
!await c() && P.current === 409 && u.warning("Someone else is editing this record — your change can’t be saved yet");
|
|
106
|
+
} finally {
|
|
107
|
+
M.current = !1;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}, [o, c]), me = Re(), J = E && me;
|
|
111
|
+
C(() => {
|
|
112
|
+
if (!o || !t || !r) return;
|
|
113
|
+
if (J) {
|
|
114
|
+
S.current && (S.current = !1, c());
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
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(() => {
|
|
119
|
+
}));
|
|
120
|
+
}, Le);
|
|
121
|
+
return () => clearTimeout(s);
|
|
122
|
+
}, [o, J, t, r, c, n, h, b]), C(() => {
|
|
123
|
+
if (!o || !t || !r) return;
|
|
124
|
+
const s = () => {
|
|
125
|
+
var k;
|
|
126
|
+
if (i.current) {
|
|
127
|
+
h(), i.current = !1, S.current = !0;
|
|
128
|
+
try {
|
|
129
|
+
const l = (k = n.getToken) == null ? void 0 : k.call(n), e = n.url ?? "";
|
|
130
|
+
fetch(
|
|
131
|
+
`${e}/api/item-locks/${encodeURIComponent(t)}/${encodeURIComponent(r)}/lock/release`,
|
|
132
|
+
{
|
|
133
|
+
method: "POST",
|
|
134
|
+
keepalive: !0,
|
|
135
|
+
credentials: l ? "omit" : "include",
|
|
136
|
+
headers: l ? { Authorization: `Bearer ${l}` } : {}
|
|
137
|
+
}
|
|
138
|
+
).catch(() => {
|
|
139
|
+
});
|
|
140
|
+
} catch {
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}, a = (k) => {
|
|
144
|
+
k.persisted && S.current && (S.current = !1, c());
|
|
145
|
+
};
|
|
146
|
+
return window.addEventListener("pagehide", s), window.addEventListener("pageshow", a), () => {
|
|
147
|
+
window.removeEventListener("pagehide", s), window.removeEventListener("pageshow", a);
|
|
148
|
+
};
|
|
149
|
+
}, [o, t, r, n, h, c]), qe(b, "lock-released", t, r, () => {
|
|
150
|
+
o && i.current && c();
|
|
86
151
|
});
|
|
87
|
-
const
|
|
152
|
+
const T = Ne(), [ke, G] = g(!1), he = x(async () => {
|
|
88
153
|
if (!(!t || !r)) {
|
|
89
|
-
|
|
154
|
+
G(!0);
|
|
90
155
|
try {
|
|
91
|
-
await
|
|
156
|
+
await n.request(L(`/item-locks/${t}/${r}/lock/request`, {})), u.success("Asked the current editor to release the lock");
|
|
92
157
|
} catch {
|
|
93
|
-
|
|
158
|
+
u.error("Could not send the lock request");
|
|
94
159
|
} finally {
|
|
95
|
-
|
|
160
|
+
G(!1);
|
|
96
161
|
}
|
|
97
162
|
}
|
|
98
|
-
}, [
|
|
99
|
-
|
|
100
|
-
if (!
|
|
101
|
-
const
|
|
163
|
+
}, [n, t, r]);
|
|
164
|
+
C(() => {
|
|
165
|
+
if (!T || !t || !r) return;
|
|
166
|
+
const s = T.on("lock:requested", (e) => {
|
|
102
167
|
if ((e == null ? void 0 : e.collection) !== t || String(e == null ? void 0 : e.item) !== String(r) || !i.current) return;
|
|
103
|
-
const
|
|
104
|
-
|
|
168
|
+
const d = (e == null ? void 0 : e.from) ?? {};
|
|
169
|
+
u(`${d.name ?? "Someone"} is asking you to release this record`, {
|
|
105
170
|
duration: 3e4,
|
|
106
171
|
action: {
|
|
107
172
|
label: "Release",
|
|
108
173
|
onClick: () => {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
to:
|
|
174
|
+
h(), i.current = !1, p(!1), n.request(
|
|
175
|
+
L(`/item-locks/${t}/${r}/lock/respond`, {
|
|
176
|
+
to: d.id,
|
|
112
177
|
action: "release"
|
|
113
178
|
})
|
|
114
|
-
).then(() =>
|
|
179
|
+
).then(() => u.success("Lock released")).catch(() => u.error("Failed to release the lock"));
|
|
115
180
|
}
|
|
116
181
|
},
|
|
117
182
|
cancel: {
|
|
118
183
|
label: "Keep editing",
|
|
119
184
|
onClick: () => {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
to:
|
|
185
|
+
n.request(
|
|
186
|
+
L(`/item-locks/${t}/${r}/lock/respond`, {
|
|
187
|
+
to: d.id,
|
|
123
188
|
action: "decline"
|
|
124
189
|
})
|
|
125
190
|
).catch(() => {
|
|
@@ -127,120 +192,121 @@ function Ce(t, r, d) {
|
|
|
127
192
|
}
|
|
128
193
|
}
|
|
129
194
|
});
|
|
130
|
-
}), a =
|
|
131
|
-
var
|
|
132
|
-
(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" ? (
|
|
133
|
-
`${((
|
|
195
|
+
}), a = T.on("lock:response", (e) => {
|
|
196
|
+
var d, y;
|
|
197
|
+
(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}"` : ""}`
|
|
134
199
|
));
|
|
135
|
-
}),
|
|
136
|
-
(e == null ? void 0 : e.collection) !== t || String(e == null ? void 0 : e.item) !== String(r) || i.current || (
|
|
137
|
-
}),
|
|
138
|
-
(e == null ? void 0 : e.collection) !== t || String(e == null ? void 0 : e.item) !== String(r) || (i.current &&
|
|
200
|
+
}), 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());
|
|
202
|
+
}), 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 }), $());
|
|
139
204
|
});
|
|
140
205
|
return () => {
|
|
141
|
-
|
|
206
|
+
s(), a(), k(), l();
|
|
142
207
|
};
|
|
143
|
-
}, [
|
|
144
|
-
const
|
|
145
|
-
var
|
|
208
|
+
}, [T, t, r, n, c, h, $]);
|
|
209
|
+
const fe = x(async () => {
|
|
210
|
+
var s;
|
|
146
211
|
if (!(!t || !r)) {
|
|
147
|
-
|
|
212
|
+
Q(!0);
|
|
148
213
|
try {
|
|
149
|
-
const a = await
|
|
150
|
-
|
|
151
|
-
),
|
|
152
|
-
|
|
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"), $();
|
|
153
218
|
} catch {
|
|
154
|
-
|
|
219
|
+
u.error("Could not join the queue");
|
|
155
220
|
} finally {
|
|
156
|
-
|
|
221
|
+
Q(!1);
|
|
157
222
|
}
|
|
158
223
|
}
|
|
159
|
-
}, [
|
|
224
|
+
}, [n, t, r, $]), be = x(async () => {
|
|
160
225
|
if (!(!t || !r))
|
|
161
226
|
try {
|
|
162
|
-
await
|
|
227
|
+
await n.request(B(`/item-locks/${t}/${r}/lock/queue`)), I(null), $();
|
|
163
228
|
} catch {
|
|
164
229
|
}
|
|
165
|
-
}, [
|
|
166
|
-
async (
|
|
230
|
+
}, [n, t, r, $]), ye = x(
|
|
231
|
+
async (s) => {
|
|
167
232
|
if (!(!t || !r || !i.current)) {
|
|
168
|
-
|
|
233
|
+
V(s);
|
|
169
234
|
try {
|
|
170
|
-
await
|
|
235
|
+
await n.request(L(`/item-locks/${t}/${r}/lock/note`, { note: s }));
|
|
171
236
|
} catch {
|
|
172
237
|
}
|
|
173
238
|
}
|
|
174
239
|
},
|
|
175
|
-
[
|
|
176
|
-
),
|
|
240
|
+
[n, t, r]
|
|
241
|
+
), ge = x(async () => {
|
|
177
242
|
if (!(!t || !r || !i.current)) {
|
|
178
|
-
|
|
243
|
+
U(!0), h(), i.current = !1, p(!1);
|
|
179
244
|
try {
|
|
180
|
-
await
|
|
245
|
+
await n.request(B(`/item-locks/${t}/${r}/lock`)), K(!0), V(""), u.success("Lock released — anyone can edit this record now");
|
|
181
246
|
} catch {
|
|
182
|
-
|
|
247
|
+
u.error("Failed to release the lock"), c();
|
|
183
248
|
} finally {
|
|
184
|
-
|
|
249
|
+
U(!1);
|
|
185
250
|
}
|
|
186
251
|
}
|
|
187
|
-
}, [
|
|
252
|
+
}, [n, t, r, h, c]), ve = x(async () => {
|
|
188
253
|
if (i.current) return !0;
|
|
189
|
-
const
|
|
190
|
-
return
|
|
191
|
-
}, [
|
|
192
|
-
var
|
|
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;
|
|
193
258
|
if (!(!t || !r)) {
|
|
194
|
-
|
|
259
|
+
A(!0);
|
|
195
260
|
try {
|
|
196
|
-
await
|
|
261
|
+
await n.request(L(`/item-locks/${t}/${r}/lock/force`, {})), u.success("You now hold the edit lock"), await c();
|
|
197
262
|
} catch (a) {
|
|
198
|
-
const
|
|
199
|
-
|
|
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 });
|
|
200
265
|
} finally {
|
|
201
|
-
|
|
266
|
+
A(!1);
|
|
202
267
|
}
|
|
203
268
|
}
|
|
204
|
-
}, [
|
|
269
|
+
}, [n, t, r, c]);
|
|
205
270
|
return {
|
|
206
|
-
lockHolder:
|
|
207
|
-
acquired:
|
|
208
|
-
isReadOnly: !!
|
|
209
|
-
takeOver:
|
|
210
|
-
takingOver:
|
|
211
|
-
isAdmin:
|
|
212
|
-
requestLock:
|
|
213
|
-
requesting:
|
|
214
|
-
queue:
|
|
215
|
-
myPosition:
|
|
216
|
-
joinQueue:
|
|
217
|
-
leaveQueue:
|
|
218
|
-
joining:
|
|
219
|
-
myNote:
|
|
220
|
-
saveNote:
|
|
221
|
-
release:
|
|
222
|
-
releasing:
|
|
223
|
-
released:
|
|
224
|
-
relock:
|
|
271
|
+
lockHolder: w,
|
|
272
|
+
acquired: _,
|
|
273
|
+
isReadOnly: !!w,
|
|
274
|
+
takeOver: xe,
|
|
275
|
+
takingOver: D,
|
|
276
|
+
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
|
|
225
291
|
};
|
|
226
292
|
}
|
|
227
|
-
function
|
|
293
|
+
function Pe({
|
|
228
294
|
note: t,
|
|
229
295
|
onSave: r,
|
|
230
|
-
waiting:
|
|
231
|
-
onRelease:
|
|
296
|
+
waiting: o,
|
|
297
|
+
onRelease: R,
|
|
232
298
|
releasing: q,
|
|
233
|
-
released:
|
|
234
|
-
onRelock:
|
|
299
|
+
released: E,
|
|
300
|
+
onRelock: n
|
|
235
301
|
}) {
|
|
236
|
-
var
|
|
237
|
-
const [
|
|
238
|
-
|
|
239
|
-
const
|
|
240
|
-
|
|
302
|
+
var v;
|
|
303
|
+
const [N, b] = g(t);
|
|
304
|
+
C(() => b(t), [t]);
|
|
305
|
+
const w = () => {
|
|
306
|
+
N.trim() !== t && r(N.trim());
|
|
241
307
|
};
|
|
242
|
-
return
|
|
243
|
-
/* @__PURE__ */
|
|
308
|
+
return E ? /* @__PURE__ */ f(te, { children: [
|
|
309
|
+
/* @__PURE__ */ m(re, { asChild: !0, children: /* @__PURE__ */ m(
|
|
244
310
|
"button",
|
|
245
311
|
{
|
|
246
312
|
type: "button",
|
|
@@ -248,117 +314,117 @@ function Se({
|
|
|
248
314
|
title: "Lock released — anyone can edit this record",
|
|
249
315
|
"data-lock-released": !0,
|
|
250
316
|
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",
|
|
251
|
-
children: /* @__PURE__ */
|
|
317
|
+
children: /* @__PURE__ */ m(H, { className: "h-4 w-4", strokeWidth: 2 })
|
|
252
318
|
}
|
|
253
319
|
) }),
|
|
254
|
-
/* @__PURE__ */
|
|
255
|
-
/* @__PURE__ */
|
|
256
|
-
/* @__PURE__ */
|
|
257
|
-
/* @__PURE__ */
|
|
258
|
-
|
|
320
|
+
/* @__PURE__ */ f(ae, { align: "end", sideOffset: 6, className: "w-[300px] p-3", children: [
|
|
321
|
+
/* @__PURE__ */ m("p", { className: "text-[12px] font-semibold text-slate-700 dark:text-slate-200", children: "You released the edit lock" }),
|
|
322
|
+
/* @__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
|
+
/* @__PURE__ */ f(
|
|
324
|
+
O,
|
|
259
325
|
{
|
|
260
326
|
type: "button",
|
|
261
327
|
size: "sm",
|
|
262
328
|
className: "mt-2 h-7 w-full text-[12px]",
|
|
263
|
-
onClick:
|
|
329
|
+
onClick: n,
|
|
264
330
|
"data-lock-relock": !0,
|
|
265
331
|
children: [
|
|
266
|
-
/* @__PURE__ */
|
|
332
|
+
/* @__PURE__ */ m(F, { className: "mr-1.5 h-3.5 w-3.5" }),
|
|
267
333
|
" Lock again"
|
|
268
334
|
]
|
|
269
335
|
}
|
|
270
336
|
)
|
|
271
337
|
] })
|
|
272
|
-
] }) : /* @__PURE__ */
|
|
273
|
-
/* @__PURE__ */
|
|
338
|
+
] }) : /* @__PURE__ */ f(te, { children: [
|
|
339
|
+
/* @__PURE__ */ m(re, { asChild: !0, children: /* @__PURE__ */ f(
|
|
274
340
|
"button",
|
|
275
341
|
{
|
|
276
342
|
type: "button",
|
|
277
343
|
"aria-label": "You hold the edit lock — add a note for others",
|
|
278
|
-
title:
|
|
344
|
+
title: o.length > 0 ? `You hold the edit lock · ${o.length} waiting` : "You hold the edit lock",
|
|
279
345
|
"data-lock-holder": !0,
|
|
280
346
|
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",
|
|
281
347
|
children: [
|
|
282
|
-
/* @__PURE__ */
|
|
283
|
-
|
|
348
|
+
/* @__PURE__ */ m(F, { className: "h-4 w-4", strokeWidth: 2 }),
|
|
349
|
+
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" })
|
|
284
350
|
]
|
|
285
351
|
}
|
|
286
352
|
) }),
|
|
287
|
-
/* @__PURE__ */
|
|
288
|
-
/* @__PURE__ */
|
|
289
|
-
/* @__PURE__ */
|
|
290
|
-
/* @__PURE__ */
|
|
353
|
+
/* @__PURE__ */ f(ae, { align: "end", sideOffset: 6, className: "w-[300px] p-3", children: [
|
|
354
|
+
/* @__PURE__ */ m("p", { className: "text-[12px] font-semibold text-slate-700 dark:text-slate-200", children: "You hold the edit lock" }),
|
|
355
|
+
/* @__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
|
+
/* @__PURE__ */ m(
|
|
291
357
|
"input",
|
|
292
358
|
{
|
|
293
|
-
value:
|
|
294
|
-
onChange: (
|
|
295
|
-
onBlur:
|
|
296
|
-
onKeyDown: (
|
|
297
|
-
|
|
359
|
+
value: N,
|
|
360
|
+
onChange: (_) => b(_.target.value.slice(0, 300)),
|
|
361
|
+
onBlur: w,
|
|
362
|
+
onKeyDown: (_) => {
|
|
363
|
+
_.key === "Enter" && (_.preventDefault(), w());
|
|
298
364
|
},
|
|
299
365
|
placeholder: "“editing lines, ~15 min”",
|
|
300
366
|
"aria-label": "Lock note",
|
|
301
367
|
className: "mt-2 h-7 w-full rounded-md border border-slate-200 bg-white px-2 text-[12px] dark:border-border dark:bg-card"
|
|
302
368
|
}
|
|
303
369
|
),
|
|
304
|
-
|
|
305
|
-
/* @__PURE__ */
|
|
306
|
-
|
|
370
|
+
o.length > 0 && /* @__PURE__ */ f("div", { className: "mt-2 rounded-md bg-amber-50 px-2 py-1.5 text-[11px] text-amber-800 dark:bg-amber-500/10 dark:text-amber-200", children: [
|
|
371
|
+
/* @__PURE__ */ f("span", { className: "font-semibold", children: [
|
|
372
|
+
o.length,
|
|
307
373
|
" waiting for the lock:"
|
|
308
374
|
] }),
|
|
309
375
|
" ",
|
|
310
|
-
|
|
376
|
+
o.map((_) => _.name ?? "someone").join(", ")
|
|
311
377
|
] }),
|
|
312
|
-
|
|
313
|
-
|
|
378
|
+
R && /* @__PURE__ */ f(
|
|
379
|
+
O,
|
|
314
380
|
{
|
|
315
381
|
type: "button",
|
|
316
382
|
variant: "outline",
|
|
317
383
|
size: "sm",
|
|
318
384
|
className: "mt-2 h-7 w-full text-[12px]",
|
|
319
|
-
onClick:
|
|
385
|
+
onClick: R,
|
|
320
386
|
disabled: q,
|
|
321
387
|
"data-lock-release": !0,
|
|
322
388
|
children: [
|
|
323
|
-
/* @__PURE__ */
|
|
324
|
-
q ? "Releasing…" :
|
|
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"
|
|
325
391
|
]
|
|
326
392
|
}
|
|
327
393
|
)
|
|
328
394
|
] })
|
|
329
395
|
] });
|
|
330
396
|
}
|
|
331
|
-
function
|
|
397
|
+
function Fe({
|
|
332
398
|
lockHolder: t,
|
|
333
399
|
onTakeOver: r,
|
|
334
|
-
takingOver:
|
|
335
|
-
isAdmin:
|
|
400
|
+
takingOver: o,
|
|
401
|
+
isAdmin: R,
|
|
336
402
|
onRequestLock: q,
|
|
337
|
-
requesting:
|
|
338
|
-
queue:
|
|
339
|
-
myPosition:
|
|
340
|
-
onJoinQueue:
|
|
341
|
-
onLeaveQueue:
|
|
342
|
-
joining:
|
|
343
|
-
noun:
|
|
344
|
-
readOnlyText:
|
|
403
|
+
requesting: E,
|
|
404
|
+
queue: n,
|
|
405
|
+
myPosition: N,
|
|
406
|
+
onJoinQueue: b,
|
|
407
|
+
onLeaveQueue: w,
|
|
408
|
+
joining: v,
|
|
409
|
+
noun: _ = "this item",
|
|
410
|
+
readOnlyText: p = "fields are read-only"
|
|
345
411
|
}) {
|
|
346
412
|
if (!t) return null;
|
|
347
|
-
const
|
|
348
|
-
return /* @__PURE__ */
|
|
413
|
+
const D = t.locked_by_name || "Another user", A = (n == null ? void 0 : n.length) ?? 0;
|
|
414
|
+
return /* @__PURE__ */ f(
|
|
349
415
|
"div",
|
|
350
416
|
{
|
|
351
417
|
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",
|
|
352
418
|
"data-lock-banner": !0,
|
|
353
419
|
children: [
|
|
354
|
-
/* @__PURE__ */
|
|
355
|
-
/* @__PURE__ */
|
|
356
|
-
/* @__PURE__ */
|
|
420
|
+
/* @__PURE__ */ m(F, { className: "h-4 w-4 shrink-0 text-amber-500" }),
|
|
421
|
+
/* @__PURE__ */ f("span", { className: "min-w-0 flex-1", children: [
|
|
422
|
+
/* @__PURE__ */ m("span", { className: "font-medium", children: D }),
|
|
357
423
|
" is editing ",
|
|
358
|
-
|
|
424
|
+
_,
|
|
359
425
|
" — ",
|
|
360
|
-
|
|
361
|
-
t.idle_minutes != null && t.idle_minutes >= 2 && /* @__PURE__ */
|
|
426
|
+
p,
|
|
427
|
+
t.idle_minutes != null && t.idle_minutes >= 2 && /* @__PURE__ */ f(
|
|
362
428
|
"span",
|
|
363
429
|
{
|
|
364
430
|
className: "ml-1.5 rounded bg-amber-100 px-1 py-px text-[10px] font-semibold text-amber-700 dark:bg-amber-500/20 dark:text-amber-200",
|
|
@@ -373,66 +439,67 @@ function Re({
|
|
|
373
439
|
),
|
|
374
440
|
" ",
|
|
375
441
|
"until the lock is released.",
|
|
376
|
-
t.note && /* @__PURE__ */
|
|
442
|
+
t.note && /* @__PURE__ */ f("span", { className: "mt-0.5 block text-[12.5px] text-amber-800/90 dark:text-amber-200/90", children: [
|
|
377
443
|
"“",
|
|
378
444
|
t.note,
|
|
379
445
|
"”"
|
|
380
446
|
] }),
|
|
381
|
-
|
|
382
|
-
|
|
447
|
+
A > 0 && N == null && /* @__PURE__ */ f("span", { className: "mt-0.5 block text-[11.5px] text-amber-700/80 dark:text-amber-300/80", children: [
|
|
448
|
+
A,
|
|
383
449
|
" ",
|
|
384
|
-
|
|
450
|
+
A === 1 ? "person is" : "people are",
|
|
385
451
|
" already waiting."
|
|
386
452
|
] })
|
|
387
453
|
] }),
|
|
388
|
-
|
|
389
|
-
|
|
454
|
+
b && (N != null ? /* @__PURE__ */ f(
|
|
455
|
+
O,
|
|
390
456
|
{
|
|
391
457
|
size: "sm",
|
|
392
458
|
variant: "outline",
|
|
393
459
|
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",
|
|
394
|
-
onClick:
|
|
460
|
+
onClick: w,
|
|
395
461
|
"data-lock-queue-leave": !0,
|
|
396
462
|
children: [
|
|
397
463
|
"You’re #",
|
|
398
|
-
|
|
464
|
+
N,
|
|
399
465
|
" in line · Leave"
|
|
400
466
|
]
|
|
401
467
|
}
|
|
402
|
-
) : /* @__PURE__ */
|
|
403
|
-
|
|
468
|
+
) : /* @__PURE__ */ m(
|
|
469
|
+
O,
|
|
404
470
|
{
|
|
405
471
|
size: "sm",
|
|
406
472
|
variant: "outline",
|
|
407
473
|
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",
|
|
408
|
-
onClick:
|
|
409
|
-
disabled:
|
|
474
|
+
onClick: b,
|
|
475
|
+
disabled: v,
|
|
410
476
|
"data-lock-queue-join": !0,
|
|
411
|
-
children:
|
|
477
|
+
children: v ? "Joining…" : "Ask to be next"
|
|
412
478
|
}
|
|
413
479
|
)),
|
|
414
|
-
q && /* @__PURE__ */
|
|
415
|
-
|
|
480
|
+
q && /* @__PURE__ */ m(
|
|
481
|
+
O,
|
|
416
482
|
{
|
|
417
483
|
size: "sm",
|
|
418
484
|
variant: "outline",
|
|
419
485
|
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",
|
|
420
486
|
onClick: q,
|
|
421
|
-
disabled:
|
|
422
|
-
children:
|
|
487
|
+
disabled: E,
|
|
488
|
+
children: E ? "Asking…" : "Ask them to wrap up"
|
|
423
489
|
}
|
|
424
490
|
),
|
|
425
|
-
// Admins always; other roles
|
|
426
|
-
// allowlist
|
|
427
|
-
|
|
428
|
-
|
|
491
|
+
// Admins always; other roles only when the server says they may (the
|
|
492
|
+
// takeover-role allowlist, #256) — unknown = offered, and a 403 then
|
|
493
|
+
// hides it. A Take over that can only fail was a dead end.
|
|
494
|
+
(R || t.may_take_over !== !1) && /* @__PURE__ */ m(
|
|
495
|
+
O,
|
|
429
496
|
{
|
|
430
497
|
size: "sm",
|
|
431
498
|
variant: "outline",
|
|
432
|
-
className:
|
|
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",
|
|
433
500
|
onClick: r,
|
|
434
|
-
disabled:
|
|
435
|
-
children:
|
|
501
|
+
disabled: o,
|
|
502
|
+
children: o ? "Taking over…" : "Take over"
|
|
436
503
|
}
|
|
437
504
|
)
|
|
438
505
|
]
|
|
@@ -440,7 +507,7 @@ function Re({
|
|
|
440
507
|
);
|
|
441
508
|
}
|
|
442
509
|
export {
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
510
|
+
Fe as ItemLockBanner,
|
|
511
|
+
Pe as LockHolderButton,
|
|
512
|
+
Me as useItemLock
|
|
446
513
|
};
|