@nivaro/react 0.3.52 → 0.3.54

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 (41) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +47 -3
  4. package/dist/shared/components/ItemEditForm.js +4196 -4163
  5. package/dist/shared/components/NotificationBell.js +163 -150
  6. package/dist/shared/components/PageRenderer.js +645 -593
  7. package/dist/shared/components/ProfileView.js +36 -34
  8. package/dist/shared/components/QueryStatStrip.js +96 -89
  9. package/dist/shared/components/QueryTable.js +214 -215
  10. package/dist/shared/components/ReportView.js +548 -529
  11. package/dist/shared/components/alerts/AlertManagerView.js +346 -320
  12. package/dist/shared/components/item-edit/CatalogPickerField.js +1300 -1219
  13. package/dist/shared/components/item-edit/DraftRecoveryBanner.js +52 -54
  14. package/dist/shared/components/item-edit/FieldAffordances.js +145 -136
  15. package/dist/shared/components/item-edit/FieldRenderer.js +366 -326
  16. package/dist/shared/components/item-edit/InlineTableField.js +3047 -2932
  17. package/dist/shared/components/item-edit/NestedRelationEditor.js +149 -143
  18. package/dist/shared/components/item-edit/PersonalDefaultControl.js +12 -11
  19. package/dist/shared/components/item-edit/PlanGrid.js +718 -705
  20. package/dist/shared/components/item-edit/RelationCombobox.js +23 -20
  21. package/dist/shared/components/item-edit/SummaryPanel.js +415 -361
  22. package/dist/shared/components/item-edit/line-qty.js +115 -53
  23. package/dist/shared/components/item-edit/save-outcome.js +48 -0
  24. package/dist/shared/components/item-edit/save-refusal.js +18 -18
  25. package/dist/shared/components/item-edit/stale-banner.js +13 -0
  26. package/dist/shared/components/item-edit/usePersonalDefaults.js +225 -220
  27. package/dist/shared/components/panels/CommentPanel.js +204 -197
  28. package/dist/shared/components/panels/ItemLockBanner.js +318 -291
  29. package/dist/shared/components/panels/PipelinePanel.js +1388 -1218
  30. package/dist/shared/components/panels/RecordIntegrityBanner.js +201 -172
  31. package/dist/shared/components/panels/RevisionsPanel.js +101 -106
  32. package/dist/shared/components/panels/TransitionRequirementsDialog.js +564 -534
  33. package/dist/shared/components/panels/requirement-side-effects.js +46 -29
  34. package/dist/shared/components/queue/QueueItemSheet.js +219 -146
  35. package/dist/shared/components/queue/QueueWorklist.js +738 -730
  36. package/dist/shared/components/widgets/ReviewListWidget.js +236 -201
  37. package/dist/shared/lib/activity-sentence.js +236 -227
  38. package/dist/shared/lib/draft-store.js +35 -29
  39. package/dist/shared/lib/page-widget-access.js +11 -0
  40. package/dist/shared/lib/record-ref.js +43 -34
  41. package/package.json +1 -1
@@ -1,15 +1,15 @@
1
1
  import { jsx as s, jsxs as h, Fragment as me } from "react/jsx-runtime";
2
- import { Copy as Q, History as fe, Eye as be, Sigma as pe, ExternalLink as xe, UserRound as ye, UserRoundPen as he, UserRoundX as ge, Lock as ke, X as ne } from "lucide-react";
3
- import { useContext as we, createContext as ve, useState as C, useCallback as N, useRef as M, useEffect as B, useLayoutEffect as Ne } from "react";
4
- import { createPortal as Ce } from "react-dom";
5
- import { toast as v } from "sonner";
6
- import { htmlToText as Se } from "../../lib/sanitize-html.js";
7
- import { cn as re, formatRelative as Z } from "../../lib/utils.js";
8
- import { useOverflowTip as Ee } from "../TipLayer.js";
9
- import { clearPersonalDefault as Te, usePersonalDefaultCss as Ue, refusalText as ee } from "./PersonalDefaultControl.js";
10
- import { PERSONAL_DEFAULT_GHOST_BUTTON as Le } from "./PersonalDefaultPill.js";
2
+ import { Copy as Z, History as be, Eye as pe, Sigma as xe, ExternalLink as ye, UserRound as he, UserRoundPen as ge, UserRoundX as ke, Lock as ve, X as re } from "lucide-react";
3
+ import { useContext as we, createContext as Ne, useState as C, useCallback as N, useRef as F, useEffect as B, useLayoutEffect as Ce } from "react";
4
+ import { createPortal as Se } from "react-dom";
5
+ import { toast as w } from "sonner";
6
+ import { htmlToText as Ee } from "../../lib/sanitize-html.js";
7
+ import { cn as ae, formatRelative as ee } from "../../lib/utils.js";
8
+ import { useOverflowTip as Te } from "../TipLayer.js";
9
+ import { clearPersonalDefault as Ue, usePersonalDefaultCss as Le, refusalText as te } from "./PersonalDefaultControl.js";
10
+ import { PERSONAL_DEFAULT_GHOST_BUTTON as Oe } from "./PersonalDefaultPill.js";
11
11
  import { usePersonalDefaultsApi as Fe } from "./usePersonalDefaults.js";
12
- const Me = ve(null), Ve = () => we(Me), te = (n) => {
12
+ const Me = Ne(null), Ye = () => we(Me), ne = (n) => {
13
13
  if (n == null || n === "") return "empty";
14
14
  if (typeof n == "boolean") return n ? "Yes" : "No";
15
15
  if (typeof n == "object")
@@ -19,10 +19,10 @@ const Me = ve(null), Ve = () => we(Me), te = (n) => {
19
19
  } catch {
20
20
  return String(n);
21
21
  }
22
- const t = String(n), o = /[<&]/.test(t) ? Se(t).trim() : t;
22
+ const t = String(n), o = /[<&]/.test(t) ? Ee(t).trim() : t;
23
23
  return o.length > 80 ? `${o.slice(0, 80)}…` : o;
24
24
  };
25
- function Xe({
25
+ function qe({
26
26
  change: n,
27
27
  onDismiss: t,
28
28
  onTakeTheirs: o
@@ -39,12 +39,12 @@ function Xe({
39
39
  n.by ?? "Someone",
40
40
  " changed this to",
41
41
  " ",
42
- /* @__PURE__ */ s("span", { className: "font-medium", children: te(n.theirs) }),
42
+ /* @__PURE__ */ s("span", { className: "font-medium", children: ne(n.theirs) }),
43
43
  " while you were editing",
44
44
  /* @__PURE__ */ h("span", { className: "text-amber-700/80 dark:text-amber-200/70", children: [
45
45
  " ",
46
46
  "· ",
47
- Z(n.at)
47
+ ee(n.at)
48
48
  ] })
49
49
  ] }),
50
50
  /* @__PURE__ */ s(
@@ -79,13 +79,13 @@ function Xe({
79
79
  /* @__PURE__ */ h("span", { className: "min-w-0 flex-1", children: [
80
80
  "was",
81
81
  " ",
82
- /* @__PURE__ */ s("span", { className: "font-medium line-through decoration-sky-400/70", children: te(n.was) }),
82
+ /* @__PURE__ */ s("span", { className: "font-medium line-through decoration-sky-400/70", children: ne(n.was) }),
83
83
  /* @__PURE__ */ h("span", { className: "text-sky-700/80 dark:text-sky-300/80", children: [
84
84
  " ",
85
85
  "· ",
86
86
  n.by ?? "someone",
87
87
  ", ",
88
- Z(n.at)
88
+ ee(n.at)
89
89
  ] })
90
90
  ] }),
91
91
  /* @__PURE__ */ s(
@@ -95,14 +95,14 @@ function Xe({
95
95
  onClick: t,
96
96
  "aria-label": "Dismiss",
97
97
  className: "shrink-0 rounded p-0.5 text-sky-500 hover:bg-sky-100 hover:text-sky-800 dark:hover:bg-sky-500/20",
98
- children: /* @__PURE__ */ s(ne, { className: "h-3 w-3" })
98
+ children: /* @__PURE__ */ s(re, { className: "h-3 w-3" })
99
99
  }
100
100
  )
101
101
  ]
102
102
  }
103
103
  );
104
104
  }
105
- function Ye({ reason: n, onHover: t }) {
105
+ function ze({ reason: n, onHover: t }) {
106
106
  return /* @__PURE__ */ s(
107
107
  "span",
108
108
  {
@@ -112,7 +112,7 @@ function Ye({ reason: n, onHover: t }) {
112
112
  "data-lock-reason": !0,
113
113
  "aria-label": n,
114
114
  role: "img",
115
- children: /* @__PURE__ */ s(ke, { className: "h-3 w-3" })
115
+ children: /* @__PURE__ */ s(ve, { className: "h-3 w-3" })
116
116
  }
117
117
  );
118
118
  }
@@ -126,21 +126,21 @@ function Re(n, t) {
126
126
  const l = n.closest("td, th");
127
127
  return l && t.contains(l) ? l.innerText.replace(/\s+/g, " ").trim() : null;
128
128
  }
129
- function qe({
129
+ function Je({
130
130
  wrapperRef: n,
131
131
  field: t,
132
132
  value: o,
133
133
  relations: l,
134
- collection: f,
134
+ collection: m,
135
135
  itemId: x,
136
- openRelated: w,
137
- editable: R = !1
136
+ openRelated: v,
137
+ editable: M = !1
138
138
  }) {
139
- var J, z;
140
- const [g, T] = C(null), r = Fe(), [k, S] = C(!1), [y, O] = C(null), [U, A] = C(null), [$, j] = C(!1), b = N((e, c) => T({ x: e, y: c }), []), [D, a] = C(null), m = M(null), L = M(null), i = N(() => {
141
- T(null), a(null), S(!1), O(null), A(null), j(!1);
142
- const e = m.current, c = L.current;
143
- m.current = null, L.current = null, (e || c) && window.setTimeout(() => {
139
+ var J, Q;
140
+ const [g, T] = C(null), r = Fe(), [k, S] = C(!1), [y, $] = C(null), [U, A] = C(null), [R, j] = C(!1), b = N((e, c) => T({ x: e, y: c }), []), [D, a] = C(null), f = F(null), L = F(null), i = N(() => {
141
+ T(null), a(null), S(!1), $(null), A(null), j(!1);
142
+ const e = f.current, c = L.current;
143
+ f.current = null, L.current = null, (e || c) && window.setTimeout(() => {
144
144
  var u;
145
145
  document.activeElement && document.activeElement !== document.body || (e != null && e.isConnected ? e.focus() : (u = c == null ? void 0 : c()) == null || u.focus());
146
146
  }, 0);
@@ -151,13 +151,13 @@ function qe({
151
151
  return;
152
152
  }
153
153
  const c = e.getBoundingClientRect();
154
- _.current = null, m.current = e, a("menu"), b(c.left, c.bottom + 4);
154
+ _.current = null, f.current = e, a("menu"), b(c.left, c.bottom + 4);
155
155
  },
156
156
  [p, i, b]
157
157
  ), E = N(() => {
158
- r && (O(null), S("save"), r.describeSave(t.field).then(
159
- (e) => O(e),
160
- () => O([])
158
+ r && ($(null), S("save"), r.describeSave(t.field).then(
159
+ (e) => $(e),
160
+ () => $([])
161
161
  ));
162
162
  }, [r, t.field]), P = N(() => {
163
163
  r && (A(null), S("update"), r.describeUpdate(t.field).then(
@@ -170,18 +170,18 @@ function qe({
170
170
  i();
171
171
  return;
172
172
  }
173
- const F = e.getBoundingClientRect();
174
- _.current = null, m.current = e, L.current = c ?? null, a(u), u === "update" ? P() : E(), b(F.right - ae, F.bottom + 4);
173
+ const O = e.getBoundingClientRect();
174
+ _.current = null, f.current = e, L.current = c ?? null, a(u), u === "update" ? P() : E(), b(O.right - oe, O.bottom + 4);
175
175
  },
176
176
  [p, D, i, b, E, P]
177
- ), _ = M(null), oe = N(
177
+ ), _ = F(null), le = N(
178
178
  (e) => {
179
- var F;
179
+ var O;
180
180
  const c = e.target;
181
- (F = window.getSelection()) != null && F.toString() && c.closest("input, textarea, [contenteditable]") || (e.preventDefault(), _.current = c, a("menu"), b(e.clientX, e.clientY));
181
+ (O = window.getSelection()) != null && O.toString() && c.closest("input, textarea, [contenteditable]") || (e.preventDefault(), _.current = c, a("menu"), b(e.clientX, e.clientY));
182
182
  },
183
183
  [b]
184
- ), le = N(
184
+ ), se = N(
185
185
  (e) => {
186
186
  var c;
187
187
  if (e.key === "ContextMenu" || e.shiftKey && e.key === "F10") {
@@ -192,95 +192,95 @@ function qe({
192
192
  },
193
193
  [b, n]
194
194
  ), I = l.find(
195
- (e) => e.many_collection === f && e.many_field === t.field && e.one_collection
195
+ (e) => e.many_collection === m && e.many_field === t.field && e.one_collection
196
196
  ), K = x && x !== "new", W = (e) => {
197
197
  var u;
198
198
  const c = (u = n.current) == null ? void 0 : u.querySelector(e);
199
199
  return c ? (c.click(), !0) : !1;
200
- }, V = !!(r != null && r.allowed(t.field)) && r.manageable(t.field), X = V && R && !!(r != null && r.hasValue(t.field)), G = V ? (r == null ? void 0 : r.defaultFor(t.field)) ?? null : null, se = X && !G, ie = X && !!G && !(r != null && r.isDefault(t.field)), Y = [
200
+ }, X = !!(r != null && r.allowed(t.field)) && r.manageable(t.field), Y = X && M && !!(r != null && r.hasValue(t.field)), G = X ? (r == null ? void 0 : r.defaultFor(t.field)) ?? null : null, ie = Y && !G, ce = Y && !!G && !(r != null && r.isDefault(t.field)), q = [
201
201
  {
202
202
  key: "copy",
203
203
  label: "Copy value",
204
- icon: /* @__PURE__ */ s(Q, { className: "h-3.5 w-3.5" }),
204
+ icon: /* @__PURE__ */ s(Z, { className: "h-3.5 w-3.5" }),
205
205
  run: () => {
206
206
  const c = Re(_.current, n.current) ?? (o == null ? "" : typeof o == "object" ? JSON.stringify(o) : String(o));
207
207
  if (!c) {
208
- v.info("Nothing to copy");
208
+ w.info("Nothing to copy");
209
209
  return;
210
210
  }
211
211
  navigator.clipboard.writeText(c).then(
212
- () => v.success("Value copied"),
213
- () => v.error("Could not copy")
212
+ () => w.success("Value copied"),
213
+ () => w.error("Could not copy")
214
214
  );
215
215
  }
216
216
  },
217
217
  {
218
218
  key: "copy-key",
219
219
  label: "Copy field key",
220
- icon: /* @__PURE__ */ s(Q, { className: "h-3.5 w-3.5" }),
220
+ icon: /* @__PURE__ */ s(Z, { className: "h-3.5 w-3.5" }),
221
221
  hint: t.field,
222
222
  run: () => {
223
223
  navigator.clipboard.writeText(t.field).then(
224
- () => v.success(`Copied “${t.field}”`),
225
- () => v.error("Could not copy")
224
+ () => w.success(`Copied “${t.field}”`),
225
+ () => w.error("Could not copy")
226
226
  );
227
227
  }
228
228
  },
229
229
  {
230
230
  key: "history",
231
231
  label: "Value history",
232
- icon: /* @__PURE__ */ s(fe, { className: "h-3.5 w-3.5" }),
232
+ icon: /* @__PURE__ */ s(be, { className: "h-3.5 w-3.5" }),
233
233
  disabled: !K,
234
234
  run: () => {
235
- W("[data-field-history]") || v.info("No history for this field yet");
235
+ W("[data-field-history]") || w.info("No history for this field yet");
236
236
  }
237
237
  },
238
238
  {
239
239
  key: "watch",
240
240
  label: "Watch this field",
241
- icon: /* @__PURE__ */ s(be, { className: "h-3.5 w-3.5" }),
241
+ icon: /* @__PURE__ */ s(pe, { className: "h-3.5 w-3.5" }),
242
242
  disabled: !K,
243
243
  run: () => {
244
- W("[data-field-watch]") || v.info("Field watching is off — an admin can enable it in Settings → Content");
244
+ W("[data-field-watch]") || w.info("Field watching is off — an admin can enable it in Settings → Content");
245
245
  }
246
246
  },
247
247
  {
248
248
  key: "explain",
249
249
  label: "Explain value",
250
- icon: /* @__PURE__ */ s(pe, { className: "h-3.5 w-3.5" }),
250
+ icon: /* @__PURE__ */ s(xe, { className: "h-3.5 w-3.5" }),
251
251
  disabled: !K || !((J = n.current) != null && J.querySelector("[data-field-lineage]")),
252
252
  run: () => {
253
253
  W("[data-field-lineage]");
254
254
  }
255
255
  },
256
- ...I && w ? [
256
+ ...I && v ? [
257
257
  {
258
258
  key: "open",
259
- label: `Open related ${(z = I.one_collection) == null ? void 0 : z.replace(/_/g, " ")}`,
260
- icon: /* @__PURE__ */ s(xe, { className: "h-3.5 w-3.5" }),
259
+ label: `Open related ${(Q = I.one_collection) == null ? void 0 : Q.replace(/_/g, " ")}`,
260
+ icon: /* @__PURE__ */ s(ye, { className: "h-3.5 w-3.5" }),
261
261
  disabled: o == null || o === "",
262
262
  run: () => {
263
263
  const e = typeof o == "object" && o && "id" in o ? String(o.id) : String(o);
264
- w(String(I.one_collection), e);
264
+ v(String(I.one_collection), e);
265
265
  }
266
266
  }
267
267
  ] : [],
268
268
  // Same states as the visible control: no default here → Save; a default holding another
269
269
  // value → Update (that default, in place); the value IS the default → only Clear.
270
- ...se ? [
270
+ ...ie ? [
271
271
  {
272
272
  key: "save-default",
273
273
  label: "Save as my default",
274
- icon: /* @__PURE__ */ s(ye, { className: "h-3.5 w-3.5" }),
274
+ icon: /* @__PURE__ */ s(he, { className: "h-3.5 w-3.5" }),
275
275
  stay: !0,
276
276
  run: E
277
277
  }
278
278
  ] : [],
279
- ...ie ? [
279
+ ...ce ? [
280
280
  {
281
281
  key: "update-default",
282
282
  label: "Update my default",
283
- icon: /* @__PURE__ */ s(he, { className: "h-3.5 w-3.5" }),
283
+ icon: /* @__PURE__ */ s(ge, { className: "h-3.5 w-3.5" }),
284
284
  stay: !0,
285
285
  run: P
286
286
  }
@@ -289,30 +289,30 @@ function qe({
289
289
  {
290
290
  key: "clear-default",
291
291
  label: "Clear my default",
292
- icon: /* @__PURE__ */ s(ge, { className: "h-3.5 w-3.5" }),
292
+ icon: /* @__PURE__ */ s(ke, { className: "h-3.5 w-3.5" }),
293
293
  // Runs at once (a menu pick is deliberate); the toast's Undo saves it back.
294
294
  run: () => {
295
- Te(r, t.field);
295
+ Ue(r, t.field);
296
296
  }
297
297
  }
298
298
  ] : []
299
- ], q = (e, c) => {
300
- const u = e.value ? ` to ${e.value}` : "", F = e.context.length ? ` for ${e.context.join(" · ")}` : "";
301
- return c ? `Updated your default${F}${u}` : `Update your default${F}${u}?`;
302
- }, ce = k === "update" && r ? {
299
+ ], z = (e, c) => {
300
+ const u = e.value ? ` to ${e.value}` : "", O = e.context.length ? ` for ${e.context.join(" · ")}` : "";
301
+ return c ? `Updated your default${O}${u}` : `Update your default${O}${u}?`;
302
+ }, de = k === "update" && r ? {
303
303
  label: "Update my default",
304
304
  action: "Update",
305
- text: U ? q(U, !1) : "Update your default?",
306
- ready: U !== null && !$,
307
- saving: $,
305
+ text: U ? z(U, !1) : "Update your default?",
306
+ ready: U !== null && !R,
307
+ saving: R,
308
308
  onCancel: i,
309
309
  onSave: () => {
310
310
  j(!0), r.update(t.field).then(
311
311
  () => {
312
- v.success(U ? q(U, !0) : "Updated your default"), i();
312
+ w.success(U ? z(U, !0) : "Updated your default"), i();
313
313
  },
314
314
  (e) => {
315
- v.error(ee(e, "Could not update your default")), i();
315
+ w.error(te(e, "Could not update your default")), i();
316
316
  }
317
317
  );
318
318
  }
@@ -320,61 +320,61 @@ function qe({
320
320
  label: "Save as my default",
321
321
  action: "Save",
322
322
  text: y != null && y.length ? `Save ${y.join(" · ")} as your ${y.length > 1 ? "defaults" : "default"}?` : "Save as your default?",
323
- ready: y !== null && !$,
324
- saving: $,
323
+ ready: y !== null && !R,
324
+ saving: R,
325
325
  onCancel: i,
326
326
  onSave: () => {
327
327
  j(!0), r.save(t.field).then(
328
328
  () => {
329
- v.success(
329
+ w.success(
330
330
  y != null && y.length ? `Saved ${y.join(" · ")} as your default${y.length > 1 ? "s" : ""}` : "Your default was saved"
331
331
  ), i();
332
332
  },
333
333
  (e) => {
334
- v.error(ee(e, "Could not save your default")), i();
334
+ w.error(te(e, "Could not save your default")), i();
335
335
  }
336
336
  );
337
337
  }
338
- } : null, de = g ? /* @__PURE__ */ s(
339
- Oe,
338
+ } : null, ue = g ? /* @__PURE__ */ s(
339
+ Ae,
340
340
  {
341
341
  at: g,
342
- items: Y,
342
+ items: q,
343
343
  onClose: i,
344
- confirm: ce,
344
+ confirm: de,
345
345
  anchor: n.current
346
346
  }
347
- ) : null, ue = Y.some(
347
+ ) : null, fe = q.some(
348
348
  (e) => e.key === "save-default" || e.key === "update-default" || e.key === "clear-default"
349
349
  );
350
350
  return {
351
- onContextMenu: oe,
352
- onKeyDown: le,
353
- menu: de,
351
+ onContextMenu: le,
352
+ onKeyDown: se,
353
+ menu: ue,
354
354
  openFrom: d,
355
355
  isOpen: p,
356
- hasFieldItems: ue,
356
+ hasFieldItems: fe,
357
357
  confirmSaveFrom: H,
358
358
  openedBy: D
359
359
  };
360
360
  }
361
- const ae = 240, $e = "[data-field-menu-trigger], [data-personal-default-make], [data-personal-default-update]";
362
- function Oe({
361
+ const oe = 240, $e = "[data-field-menu-trigger], [data-personal-default-make], [data-personal-default-update]";
362
+ function Ae({
363
363
  at: n,
364
364
  items: t,
365
365
  onClose: o,
366
366
  confirm: l,
367
- anchor: f
367
+ anchor: m
368
368
  }) {
369
- Ue();
370
- const x = M(null), [w, R] = C(0), g = t.filter((a) => !a.disabled);
369
+ Le();
370
+ const x = F(null), [v, M] = C(0), g = t.filter((a) => !a.disabled);
371
371
  B(() => {
372
372
  var L;
373
373
  const a = (i) => {
374
374
  var d, E;
375
375
  const p = i.target;
376
- (d = x.current) != null && d.contains(p) || (E = p == null ? void 0 : p.closest) != null && E.call(p, $e) && (f != null && f.contains(p)) || o();
377
- }, m = (i) => {
376
+ (d = x.current) != null && d.contains(p) || (E = p == null ? void 0 : p.closest) != null && E.call(p, $e) && (m != null && m.contains(p)) || o();
377
+ }, f = (i) => {
378
378
  var p;
379
379
  if (i.key === "Escape")
380
380
  i.preventDefault(), o();
@@ -390,44 +390,44 @@ function Oe({
390
390
  }
391
391
  return;
392
392
  } else if (i.key === "ArrowDown")
393
- i.preventDefault(), R((d) => (d + 1) % Math.max(1, g.length));
393
+ i.preventDefault(), M((d) => (d + 1) % Math.max(1, g.length));
394
394
  else if (i.key === "ArrowUp")
395
- i.preventDefault(), R((d) => (d - 1 + Math.max(1, g.length)) % Math.max(1, g.length));
395
+ i.preventDefault(), M((d) => (d - 1 + Math.max(1, g.length)) % Math.max(1, g.length));
396
396
  else if (i.key === "Enter" || i.key === " ") {
397
397
  i.preventDefault();
398
- const d = g[w];
398
+ const d = g[v];
399
399
  d && (d.run(), d.stay || o());
400
400
  }
401
401
  };
402
- return window.addEventListener("mousedown", a, !0), window.addEventListener("keydown", m, !0), (L = x.current) == null || L.focus(), () => {
403
- window.removeEventListener("mousedown", a, !0), window.removeEventListener("keydown", m, !0);
402
+ return window.addEventListener("mousedown", a, !0), window.addEventListener("keydown", f, !0), (L = x.current) == null || L.focus(), () => {
403
+ window.removeEventListener("mousedown", a, !0), window.removeEventListener("keydown", f, !0);
404
404
  };
405
- }, [o, g, w, l, f]);
406
- const T = M(null), r = M(null), k = !!l, S = !!(l != null && l.ready);
405
+ }, [o, g, v, l, m]);
406
+ const T = F(null), r = F(null), k = !!l, S = !!(l != null && l.ready);
407
407
  B(() => {
408
408
  var a;
409
409
  k && ((a = r.current) == null || a.focus());
410
410
  }, [k]), B(() => {
411
- var m;
411
+ var f;
412
412
  if (!S) return;
413
413
  const a = document.activeElement;
414
- (a === r.current || a === x.current || a === document.body) && ((m = T.current) == null || m.focus());
414
+ (a === r.current || a === x.current || a === document.body) && ((f = T.current) == null || f.focus());
415
415
  }, [S]);
416
- const y = Math.min(ae, window.innerWidth - 16), O = Ee(l == null ? void 0 : l.text), [U, A] = C(() => l ? 96 : t.length * 30 + 12);
417
- Ne(() => {
418
- var m;
419
- const a = (m = x.current) == null ? void 0 : m.offsetHeight;
416
+ const y = Math.min(oe, window.innerWidth - 16), $ = Te(l == null ? void 0 : l.text), [U, A] = C(() => l ? 96 : t.length * 30 + 12);
417
+ Ce(() => {
418
+ var f;
419
+ const a = (f = x.current) == null ? void 0 : f.offsetHeight;
420
420
  a && a !== U && A(a);
421
421
  });
422
- const $ = Math.max(8, Math.min(n.x, window.innerWidth - y - 8)), j = Math.max(8, Math.min(n.y, window.innerHeight - U - 8)), b = (f == null ? void 0 : f.closest('[role="dialog"]')) ?? document.body, D = b === document.body ? { position: "fixed", left: $, top: j } : (() => {
422
+ const R = Math.max(8, Math.min(n.x, window.innerWidth - y - 8)), j = Math.max(8, Math.min(n.y, window.innerHeight - U - 8)), b = (m == null ? void 0 : m.closest('[role="dialog"]')) ?? document.body, D = b === document.body ? { position: "fixed", left: R, top: j } : (() => {
423
423
  const a = b.getBoundingClientRect();
424
424
  return {
425
425
  position: "absolute",
426
- left: $ - a.left + b.scrollLeft - b.clientLeft,
426
+ left: R - a.left + b.scrollLeft - b.clientLeft,
427
427
  top: j - a.top + b.scrollTop - b.clientTop
428
428
  };
429
429
  })();
430
- return Ce(
430
+ return Se(
431
431
  /* @__PURE__ */ h(
432
432
  "div",
433
433
  {
@@ -442,7 +442,7 @@ function Oe({
442
442
  /* @__PURE__ */ s(
443
443
  "p",
444
444
  {
445
- ref: O,
445
+ ref: $,
446
446
  "aria-live": "polite",
447
447
  className: "line-clamp-4 text-[12.5px] leading-snug text-slate-700 [overflow-wrap:anywhere] dark:text-slate-200",
448
448
  children: l.text
@@ -455,9 +455,9 @@ function Oe({
455
455
  ref: r,
456
456
  type: "button",
457
457
  onClick: l.onCancel,
458
- className: Le,
458
+ className: Oe,
459
459
  children: [
460
- /* @__PURE__ */ s(ne, { className: "h-3 w-3", "aria-hidden": !0 }),
460
+ /* @__PURE__ */ s(re, { className: "h-3 w-3", "aria-hidden": !0 }),
461
461
  " Cancel"
462
462
  ]
463
463
  }
@@ -476,18 +476,18 @@ function Oe({
476
476
  ] })
477
477
  ] }) : null,
478
478
  l ? null : t.map((a) => {
479
- const m = g.indexOf(a), L = m === w && !a.disabled;
479
+ const f = g.indexOf(a), L = f === v && !a.disabled;
480
480
  return /* @__PURE__ */ h(
481
481
  "button",
482
482
  {
483
483
  type: "button",
484
484
  role: "menuitem",
485
485
  disabled: a.disabled,
486
- onMouseEnter: () => m >= 0 && R(m),
486
+ onMouseEnter: () => f >= 0 && M(f),
487
487
  onClick: () => {
488
488
  a.run(), a.stay || o();
489
489
  },
490
- className: re(
490
+ className: ae(
491
491
  "flex h-[30px] w-full items-center gap-2 rounded-sm px-2 text-left text-[12.5px] font-medium text-slate-700 dark:text-slate-200",
492
492
  L && "bg-accent text-accent-foreground",
493
493
  a.disabled && "cursor-not-allowed opacity-40"
@@ -507,8 +507,15 @@ function Oe({
507
507
  b
508
508
  );
509
509
  }
510
- function Je(n) {
511
- const [t, o] = C(null), [l, f] = C(!1), x = M(!1), w = M(null);
510
+ const V = /* @__PURE__ */ new Set();
511
+ function Qe(n, t) {
512
+ t ? V.add(n) : V.delete(n);
513
+ }
514
+ function je() {
515
+ return V.size > 0;
516
+ }
517
+ function Ze(n) {
518
+ const [t, o] = C(null), [l, m] = C(!1), x = F(!1), v = F(null);
512
519
  B(() => {
513
520
  const r = n.current;
514
521
  if (!r) return;
@@ -517,43 +524,43 @@ function Je(n) {
517
524
  const S = new MutationObserver(k);
518
525
  return S.observe(r, { attributes: !0, attributeFilter: ["data-remote-editor"] }), () => S.disconnect();
519
526
  }, [n]), B(() => {
520
- t || (f(!1), x.current = !1);
527
+ t || (m(!1), x.current = !1);
521
528
  }, [t]);
522
- const R = N(
529
+ const M = N(
523
530
  (r) => {
524
- if (!t || x.current) return;
531
+ if (!t || x.current || je()) return;
525
532
  const k = r.target;
526
- k.matches('input, textarea, select, [contenteditable="true"], [role="combobox"]') && (w.current = k, setTimeout(() => {
533
+ k.matches('input, textarea, select, [contenteditable="true"], [role="combobox"]') && (v.current = k, setTimeout(() => {
527
534
  x.current || k.blur();
528
- }, 0), f(!0));
535
+ }, 0), m(!0));
529
536
  },
530
537
  [t]
531
538
  ), g = N(() => {
532
- x.current = !0, f(!1);
533
- const r = w.current;
534
- w.current = null, r && setTimeout(() => r.focus(), 0);
539
+ x.current = !0, m(!1);
540
+ const r = v.current;
541
+ v.current = null, r && setTimeout(() => r.focus(), 0);
535
542
  }, []), T = N(() => {
536
- f(!1), w.current = null;
543
+ m(!1), v.current = null;
537
544
  }, []);
538
- return { editor: t, confirming: l, onFocusCapture: R, confirm: g, cancel: T };
545
+ return { editor: t, confirming: l, onFocusCapture: M, confirm: g, cancel: T };
539
546
  }
540
- function ze({
547
+ function et({
541
548
  editor: n,
542
549
  confirming: t,
543
550
  onConfirm: o,
544
551
  onCancel: l
545
552
  }) {
546
- const f = n.split(/\s+/).map((x) => x[0]).filter(Boolean).slice(0, 2).join("").toUpperCase();
553
+ const m = n.split(/\s+/).map((x) => x[0]).filter(Boolean).slice(0, 2).join("").toUpperCase();
547
554
  return /* @__PURE__ */ h(
548
555
  "div",
549
556
  {
550
557
  "data-presence-soft-lock": !0,
551
- className: re(
558
+ className: ae(
552
559
  "flex flex-wrap items-center gap-2 rounded-md px-2 py-1 text-[11.5px]",
553
560
  t ? "border border-amber-300 bg-amber-50 text-amber-900 dark:border-amber-500/40 dark:bg-amber-500/10 dark:text-amber-100" : "text-amber-700 dark:text-amber-300"
554
561
  ),
555
562
  children: [
556
- /* @__PURE__ */ s("span", { className: "inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-amber-200 text-[9px] font-semibold text-amber-900 dark:bg-amber-500/40 dark:text-amber-50", children: f || "?" }),
563
+ /* @__PURE__ */ s("span", { className: "inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-amber-200 text-[9px] font-semibold text-amber-900 dark:bg-amber-500/40 dark:text-amber-50", children: m || "?" }),
557
564
  /* @__PURE__ */ s("span", { className: "min-w-0 flex-1", children: t ? `${n} is typing here — edit anyway?` : `${n} is editing this field` }),
558
565
  t && /* @__PURE__ */ h(me, { children: [
559
566
  /* @__PURE__ */ s(
@@ -581,11 +588,13 @@ function ze({
581
588
  }
582
589
  export {
583
590
  Me as FieldAffordancesContext,
584
- Ye as LockReasonBadge,
585
- ze as PresenceSoftLockStrip,
586
- Xe as RemoteChangeGhost,
587
- te as ghostText,
588
- Ve as useFieldAffordances,
589
- qe as useFieldContextMenu,
590
- Je as usePresenceSoftLock
591
+ ze as LockReasonBadge,
592
+ et as PresenceSoftLockStrip,
593
+ qe as RemoteChangeGhost,
594
+ ne as ghostText,
595
+ je as holdsLockByTakeOver,
596
+ Qe as noteTakeOverHold,
597
+ Ye as useFieldAffordances,
598
+ Je as useFieldContextMenu,
599
+ Ze as usePresenceSoftLock
591
600
  };