@nivaro/react 0.3.13 → 0.3.15

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 (48) 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 +33 -2
  5. package/dist/index.js +520 -516
  6. package/dist/shared/components/CollectionBrowserView.js +2393 -2318
  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/RowComments.js +1 -3
  27. package/dist/shared/components/item-edit/SummaryPanel.js +62 -62
  28. package/dist/shared/components/item-edit/UserChip.js +113 -113
  29. package/dist/shared/components/item-edit/file-download.js +18 -0
  30. package/dist/shared/components/item-edit/line-qty.js +67 -32
  31. package/dist/shared/components/item-edit/save-refusal.js +23 -0
  32. package/dist/shared/components/monitoring/TrafficMiniMap.js +9 -9
  33. package/dist/shared/components/panels/CommentPanel.js +30 -30
  34. package/dist/shared/components/panels/ItemLockBanner.js +207 -185
  35. package/dist/shared/components/panels/PipelinePanel.js +915 -786
  36. package/dist/shared/components/pipeline/PipelineEditorView.js +45 -25
  37. package/dist/shared/components/profile/DelegationCard.js +1 -1
  38. package/dist/shared/components/profile/session-actions.js +24 -24
  39. package/dist/shared/components/queue/QueueItemSheet.js +18 -18
  40. package/dist/shared/components/queue/QueueWorklist.js +517 -504
  41. package/dist/shared/components/ui/dropdown-menu.js +8 -7
  42. package/dist/shared/lib/draft-store.js +60 -33
  43. package/dist/shared/lib/leave-guard.js +38 -0
  44. package/dist/shared/lib/load-error.js +38 -17
  45. package/dist/shared/lib/summary-mode.js +25 -25
  46. package/dist/shared/lib/table-pins.js +23 -0
  47. package/dist/shared/lib/validation-rules.js +55 -51
  48. package/package.json +1 -1
@@ -1,115 +1,142 @@
1
- import { jsxs as n, jsx as a } from "react/jsx-runtime";
2
- import { History as v, RotateCcw as w, Trash2 as y } from "lucide-react";
3
- import { useState as $ } from "react";
4
- import { formatRelative as j, titleCase as h } from "../../lib/utils.js";
5
- const x = (t) => {
6
- if (t == null || t === "") return "empty";
7
- if (typeof t == "boolean") return t ? "Yes" : "No";
8
- const c = typeof t == "object" ? JSON.stringify(t) : String(t);
1
+ import { jsxs as t, jsx as n } from "react/jsx-runtime";
2
+ import { History as _, ExternalLink as C, RotateCcw as R, Trash2 as S } from "lucide-react";
3
+ import { useState as D } from "react";
4
+ import { useItemNavigation as H } from "../../context.js";
5
+ import { formatRelative as v, titleCase as k } from "../../lib/utils.js";
6
+ const w = (r) => {
7
+ if (r == null || r === "") return "empty";
8
+ if (typeof r == "boolean") return r ? "Yes" : "No";
9
+ const c = typeof r == "object" ? JSON.stringify(r) : String(r);
9
10
  return c.length > 60 ? `${c.slice(0, 60)}…` : c;
10
11
  };
11
- function S({
12
- draft: t,
12
+ function L({
13
+ draft: r,
13
14
  labelFor: c,
14
- current: u,
15
- recordChanged: g,
16
- onRestore: f,
17
- onDiscard: N
15
+ current: g,
16
+ recordChanged: y,
17
+ onRestore: $,
18
+ onDiscard: j,
19
+ createdId: s = null,
20
+ collection: x,
21
+ renderValue: p
18
22
  }) {
19
- const [b, k] = $(!1), m = Object.entries(t.fields ?? {}), p = Object.values(t.pending_rows ?? {}).reduce((e, r) => e + r.length, 0), l = Object.values(t.pending_edits ?? {}).reduce(
20
- (e, r) => e + Object.keys(r).length,
23
+ const [f, O] = D(!1), N = H(), b = Object.entries(r.fields ?? {}), h = s !== null, u = Object.values(r.pending_rows ?? {}).reduce((e, a) => e + a.length, 0), l = Object.values(r.pending_edits ?? {}).reduce(
24
+ (e, a) => e + Object.keys(a).length,
21
25
  0
22
- ), i = Object.values(t.pending_deletes ?? {}).reduce((e, r) => e + r.length, 0), d = Object.values(t.m2m_links ?? {}).reduce((e, r) => e + r.length, 0), o = Object.values(t.m2m_unlinks ?? {}).reduce((e, r) => e + r.length, 0), s = [];
23
- return m.length && s.push(`${m.length} field${m.length === 1 ? "" : "s"}`), p && s.push(`${p} new line${p === 1 ? "" : "s"}`), l && s.push(`${l} line edit${l === 1 ? "" : "s"}`), i && s.push(`${i} line removal${i === 1 ? "" : "s"}`), d && s.push(`${d} link${d === 1 ? "" : "s"}`), o && s.push(`${o} unlink${o === 1 ? "" : "s"}`), /* @__PURE__ */ n(
26
+ ), o = Object.values(r.pending_deletes ?? {}).reduce((e, a) => e + a.length, 0), m = Object.values(r.m2m_links ?? {}).reduce((e, a) => e + a.length, 0), d = Object.values(r.m2m_unlinks ?? {}).reduce((e, a) => e + a.length, 0), i = [];
27
+ return b.length && i.push(`${b.length} field${b.length === 1 ? "" : "s"}`), u && i.push(`${u} new line${u === 1 ? "" : "s"}`), l && i.push(`${l} line edit${l === 1 ? "" : "s"}`), o && i.push(`${o} line removal${o === 1 ? "" : "s"}`), m && i.push(`${m} link${m === 1 ? "" : "s"}`), d && i.push(`${d} unlink${d === 1 ? "" : "s"}`), /* @__PURE__ */ t(
24
28
  "div",
25
29
  {
26
30
  className: "mb-2 rounded-md border border-amber-300 bg-amber-50 px-3 py-2 text-[12.5px] text-amber-900 dark:border-amber-500/40 dark:bg-amber-500/10 dark:text-amber-200",
27
31
  "data-nvr-draft-recovery": !0,
28
32
  children: [
29
- /* @__PURE__ */ n("div", { className: "flex flex-wrap items-center gap-2", children: [
30
- /* @__PURE__ */ a(v, { className: "h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400" }),
31
- /* @__PURE__ */ n("span", { className: "min-w-0 flex-1", children: [
32
- /* @__PURE__ */ n("span", { className: "font-semibold", children: [
33
+ /* @__PURE__ */ t("div", { className: "flex flex-wrap items-center gap-2", children: [
34
+ /* @__PURE__ */ n(_, { className: "h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400" }),
35
+ /* @__PURE__ */ t("span", { className: "min-w-0 flex-1", children: [
36
+ h ? /* @__PURE__ */ t("span", { className: "font-semibold", "data-nvr-draft-created": !0, children: [
37
+ "These changes from ",
38
+ v(r.saved_at),
39
+ " were already saved",
40
+ s ? ` as record ${s}` : " as a new record",
41
+ " — restoring them makes a second one."
42
+ ] }) : /* @__PURE__ */ t("span", { className: "font-semibold", children: [
33
43
  "Restore your unsaved changes from ",
34
- j(t.saved_at),
44
+ v(r.saved_at),
35
45
  "?"
36
46
  ] }),
37
47
  " ",
38
- /* @__PURE__ */ a("span", { className: "text-amber-800/80 dark:text-amber-200/80", children: s.join(" · ") }),
39
- g && /* @__PURE__ */ a("span", { className: "ml-1 rounded bg-amber-200/70 px-1 py-px text-[10.5px] font-semibold uppercase tracking-wide text-amber-900 dark:bg-amber-500/30 dark:text-amber-100", children: "record changed since — review before restoring" })
48
+ /* @__PURE__ */ n("span", { className: "text-amber-800/80 dark:text-amber-200/80", children: i.join(" · ") }),
49
+ y && /* @__PURE__ */ n("span", { className: "ml-1 rounded bg-amber-200/70 px-1 py-px text-[10.5px] font-semibold uppercase tracking-wide text-amber-900 dark:bg-amber-500/30 dark:text-amber-100", children: "record changed since — review before restoring" })
40
50
  ] }),
41
- /* @__PURE__ */ a(
51
+ /* @__PURE__ */ n(
42
52
  "button",
43
53
  {
44
54
  type: "button",
45
- onClick: () => k((e) => !e),
55
+ onClick: () => O((e) => !e),
46
56
  className: "text-[11.5px] underline decoration-dotted underline-offset-2",
47
- children: b ? "Hide changes" : "Show changes"
57
+ children: f ? "Hide changes" : "Show changes"
48
58
  }
49
59
  ),
50
- /* @__PURE__ */ n(
60
+ h && s && x && /* @__PURE__ */ t(
61
+ "a",
62
+ {
63
+ href: N.urlFor({ collection: x, itemId: s }),
64
+ onClick: (e) => {
65
+ e.preventDefault(), N.open({ collection: x, itemId: s });
66
+ },
67
+ className: "inline-flex h-7 items-center gap-1 rounded-md bg-amber-600 px-2.5 text-[11.5px] font-semibold text-white hover:bg-amber-700",
68
+ "data-nvr-draft-open-created": !0,
69
+ children: [
70
+ /* @__PURE__ */ n(C, { className: "h-3 w-3" }),
71
+ " Open record ",
72
+ s
73
+ ]
74
+ }
75
+ ),
76
+ /* @__PURE__ */ t(
51
77
  "button",
52
78
  {
53
79
  type: "button",
54
- onClick: f,
55
- className: "inline-flex h-7 items-center gap-1 rounded-md bg-amber-600 px-2.5 text-[11.5px] font-semibold text-white hover:bg-amber-700",
80
+ onClick: $,
81
+ className: h ? "inline-flex h-7 items-center gap-1 rounded-md border border-amber-300 px-2.5 text-[11.5px] font-medium hover:bg-amber-100 dark:border-amber-500/40 dark:hover:bg-amber-500/15" : "inline-flex h-7 items-center gap-1 rounded-md bg-amber-600 px-2.5 text-[11.5px] font-semibold text-white hover:bg-amber-700",
56
82
  "data-nvr-draft-restore": !0,
57
83
  children: [
58
- /* @__PURE__ */ a(w, { className: "h-3 w-3" }),
59
- " Restore"
84
+ /* @__PURE__ */ n(R, { className: "h-3 w-3" }),
85
+ " ",
86
+ h ? "Restore anyway" : "Restore"
60
87
  ]
61
88
  }
62
89
  ),
63
- /* @__PURE__ */ n(
90
+ /* @__PURE__ */ t(
64
91
  "button",
65
92
  {
66
93
  type: "button",
67
- onClick: N,
94
+ onClick: j,
68
95
  className: "inline-flex h-7 items-center gap-1 rounded-md border border-amber-300 px-2.5 text-[11.5px] font-medium hover:bg-amber-100 dark:border-amber-500/40 dark:hover:bg-amber-500/15",
69
96
  "data-nvr-draft-discard": !0,
70
97
  children: [
71
- /* @__PURE__ */ a(y, { className: "h-3 w-3" }),
98
+ /* @__PURE__ */ n(S, { className: "h-3 w-3" }),
72
99
  " Discard"
73
100
  ]
74
101
  }
75
102
  )
76
103
  ] }),
77
- b && /* @__PURE__ */ n("div", { className: "mt-2 max-h-[240px] space-y-1 overflow-y-auto border-t border-amber-200/70 pt-2 dark:border-amber-500/30", children: [
78
- m.map(([e, r]) => /* @__PURE__ */ n("div", { className: "text-[11.5px]", children: [
79
- /* @__PURE__ */ a("span", { className: "font-medium", children: c(e) || h(e.replace(/_/g, " ")) }),
80
- /* @__PURE__ */ n("p", { className: "break-words text-amber-800/80 dark:text-amber-200/80", children: [
81
- /* @__PURE__ */ a("span", { className: "line-through opacity-70", children: x(u[e]) }),
104
+ f && /* @__PURE__ */ t("div", { className: "mt-2 max-h-[240px] space-y-1 overflow-y-auto border-t border-amber-200/70 pt-2 dark:border-amber-500/30", children: [
105
+ b.map(([e, a]) => /* @__PURE__ */ t("div", { className: "text-[11.5px]", children: [
106
+ /* @__PURE__ */ n("span", { className: "font-medium", children: c(e) || k(e.replace(/_/g, " ")) }),
107
+ /* @__PURE__ */ t("p", { className: "break-words text-amber-800/80 dark:text-amber-200/80", children: [
108
+ /* @__PURE__ */ n("span", { className: "line-through opacity-70", children: p ? p(e, g[e]) : w(g[e]) }),
82
109
  " ",
83
- /* @__PURE__ */ a("span", { className: "font-medium text-amber-900 dark:text-amber-100", children: x(r) })
110
+ /* @__PURE__ */ n("span", { className: "font-medium text-amber-900 dark:text-amber-100", children: p ? p(e, a) : w(a) })
84
111
  ] })
85
112
  ] }, e)),
86
- Object.entries(t.pending_rows ?? {}).filter(([, e]) => e.length > 0).map(([e, r]) => /* @__PURE__ */ n("p", { className: "text-[11.5px]", children: [
87
- r.length,
113
+ Object.entries(r.pending_rows ?? {}).filter(([, e]) => e.length > 0).map(([e, a]) => /* @__PURE__ */ t("p", { className: "text-[11.5px]", children: [
114
+ a.length,
88
115
  " new line",
89
- r.length === 1 ? "" : "s",
116
+ a.length === 1 ? "" : "s",
90
117
  " in",
91
118
  " ",
92
- h(e.split(".")[0].replace(/_/g, " "))
119
+ k(e.split(".")[0].replace(/_/g, " "))
93
120
  ] }, e)),
94
- l > 0 && /* @__PURE__ */ n("p", { className: "text-[11.5px]", children: [
121
+ l > 0 && /* @__PURE__ */ t("p", { className: "text-[11.5px]", children: [
95
122
  l,
96
123
  " edited line",
97
124
  l === 1 ? "" : "s"
98
125
  ] }),
99
- i > 0 && /* @__PURE__ */ n("p", { className: "text-[11.5px]", children: [
100
- i,
126
+ o > 0 && /* @__PURE__ */ t("p", { className: "text-[11.5px]", children: [
127
+ o,
101
128
  " line removal",
102
- i === 1 ? "" : "s"
129
+ o === 1 ? "" : "s"
103
130
  ] }),
104
- d > 0 && /* @__PURE__ */ n("p", { className: "text-[11.5px]", children: [
105
- d,
131
+ m > 0 && /* @__PURE__ */ t("p", { className: "text-[11.5px]", children: [
132
+ m,
106
133
  " relation link",
107
- d === 1 ? "" : "s"
134
+ m === 1 ? "" : "s"
108
135
  ] }),
109
- o > 0 && /* @__PURE__ */ n("p", { className: "text-[11.5px]", children: [
110
- o,
136
+ d > 0 && /* @__PURE__ */ t("p", { className: "text-[11.5px]", children: [
137
+ d,
111
138
  " relation removal",
112
- o === 1 ? "" : "s"
139
+ d === 1 ? "" : "s"
113
140
  ] })
114
141
  ] })
115
142
  ]
@@ -117,5 +144,5 @@ function S({
117
144
  );
118
145
  }
119
146
  export {
120
- S as DraftRecoveryBanner
147
+ L as DraftRecoveryBanner
121
148
  };
@@ -3,21 +3,22 @@ import { Copy as F, History as O, Eye as K, Sigma as P, ExternalLink as B, Lock
3
3
  import { useContext as U, createContext as q, useState as C, useCallback as g, useRef as v, useEffect as E } from "react";
4
4
  import { createPortal as J } from "react-dom";
5
5
  import { toast as k } from "sonner";
6
- import { cn as T, formatRelative as j } from "../../lib/utils.js";
7
- const R = q(null), te = () => U(R), A = (e) => {
6
+ import { htmlToText as R } from "../../lib/sanitize-html.js";
7
+ import { cn as A, formatRelative as T } from "../../lib/utils.js";
8
+ const V = q(null), re = () => U(V), j = (e) => {
8
9
  if (e == null || e === "") return "empty";
9
10
  if (typeof e == "boolean") return e ? "Yes" : "No";
10
11
  if (typeof e == "object")
11
12
  try {
12
- const t = JSON.stringify(e);
13
- return t.length > 80 ? `${t.slice(0, 80)}…` : t;
13
+ const s = JSON.stringify(e);
14
+ return s.length > 80 ? `${s.slice(0, 80)}…` : s;
14
15
  } catch {
15
16
  return String(e);
16
17
  }
17
- const n = String(e).replace(/<[^>]+>/g, "");
18
- return n.length > 80 ? `${n.slice(0, 80)}…` : n;
18
+ const n = String(e), t = /[<&]/.test(n) ? R(n).trim() : n;
19
+ return t.length > 80 ? `${t.slice(0, 80)}…` : t;
19
20
  };
20
- function ne({
21
+ function oe({
21
22
  change: e,
22
23
  onDismiss: n,
23
24
  onTakeTheirs: t
@@ -34,12 +35,12 @@ function ne({
34
35
  e.by ?? "Someone",
35
36
  " changed this to",
36
37
  " ",
37
- /* @__PURE__ */ o("span", { className: "font-medium", children: A(e.theirs) }),
38
+ /* @__PURE__ */ o("span", { className: "font-medium", children: j(e.theirs) }),
38
39
  " while you were editing",
39
40
  /* @__PURE__ */ x("span", { className: "text-amber-700/80 dark:text-amber-200/70", children: [
40
41
  " ",
41
42
  "· ",
42
- j(e.at)
43
+ T(e.at)
43
44
  ] })
44
45
  ] }),
45
46
  /* @__PURE__ */ o(
@@ -74,13 +75,13 @@ function ne({
74
75
  /* @__PURE__ */ x("span", { className: "min-w-0 flex-1", children: [
75
76
  "was",
76
77
  " ",
77
- /* @__PURE__ */ o("span", { className: "font-medium line-through decoration-sky-400/70", children: A(e.was) }),
78
+ /* @__PURE__ */ o("span", { className: "font-medium line-through decoration-sky-400/70", children: j(e.was) }),
78
79
  /* @__PURE__ */ x("span", { className: "text-sky-700/80 dark:text-sky-300/80", children: [
79
80
  " ",
80
81
  "· ",
81
82
  e.by ?? "someone",
82
83
  ", ",
83
- j(e.at)
84
+ T(e.at)
84
85
  ] })
85
86
  ] }),
86
87
  /* @__PURE__ */ o(
@@ -97,7 +98,7 @@ function ne({
97
98
  }
98
99
  );
99
100
  }
100
- function re({ reason: e, onHover: n }) {
101
+ function ae({ reason: e, onHover: n }) {
101
102
  return /* @__PURE__ */ o(
102
103
  "span",
103
104
  {
@@ -111,24 +112,24 @@ function re({ reason: e, onHover: n }) {
111
112
  }
112
113
  );
113
114
  }
114
- function V(e, n) {
115
+ function W(e, n) {
115
116
  if (!e || !(n != null && n.contains(e))) return null;
116
117
  const t = e.closest(
117
118
  "input, textarea, select"
118
119
  );
119
120
  if (t && n.contains(t) && !(t instanceof HTMLInputElement && t.type === "checkbox"))
120
121
  return t.value;
121
- const l = e.closest("td, th");
122
- return l && n.contains(l) ? l.innerText.replace(/\s+/g, " ").trim() : null;
122
+ const s = e.closest("td, th");
123
+ return s && n.contains(s) ? s.innerText.replace(/\s+/g, " ").trim() : null;
123
124
  }
124
- function oe({
125
+ function se({
125
126
  wrapperRef: e,
126
127
  field: n,
127
128
  value: t,
128
- relations: l,
129
+ relations: s,
129
130
  collection: m,
130
131
  itemId: c,
131
- openRelated: i
132
+ openRelated: l
132
133
  }) {
133
134
  var M, D;
134
135
  const [y, w] = C(null), h = g((a, u) => w({ x: a, y: u }), []), b = g(() => w(null), []), r = v(null), f = g(
@@ -148,7 +149,7 @@ function oe({
148
149
  }
149
150
  },
150
151
  [h, e]
151
- ), s = l.find(
152
+ ), i = s.find(
152
153
  (a) => a.many_collection === m && a.many_field === n.field && a.one_collection
153
154
  ), d = c && c !== "new", S = (a) => {
154
155
  var p;
@@ -160,7 +161,7 @@ function oe({
160
161
  label: "Copy value",
161
162
  icon: /* @__PURE__ */ o(F, { className: "h-3.5 w-3.5" }),
162
163
  run: () => {
163
- const u = V(r.current, e.current) ?? (t == null ? "" : typeof t == "object" ? JSON.stringify(t) : String(t));
164
+ const u = W(r.current, e.current) ?? (t == null ? "" : typeof t == "object" ? JSON.stringify(t) : String(t));
164
165
  if (!u) {
165
166
  k.info("Nothing to copy");
166
167
  return;
@@ -210,62 +211,62 @@ function oe({
210
211
  S("[data-field-lineage]");
211
212
  }
212
213
  },
213
- ...s && i ? [
214
+ ...i && l ? [
214
215
  {
215
216
  key: "open",
216
- label: `Open related ${(D = s.one_collection) == null ? void 0 : D.replace(/_/g, " ")}`,
217
+ label: `Open related ${(D = i.one_collection) == null ? void 0 : D.replace(/_/g, " ")}`,
217
218
  icon: /* @__PURE__ */ o(B, { className: "h-3.5 w-3.5" }),
218
219
  disabled: t == null || t === "",
219
220
  run: () => {
220
221
  const a = typeof t == "object" && t && "id" in t ? String(t.id) : String(t);
221
- i(String(s.one_collection), a);
222
+ l(String(i.one_collection), a);
222
223
  }
223
224
  }
224
225
  ] : []
225
226
  ];
226
- return { onContextMenu: f, onKeyDown: N, menu: y ? /* @__PURE__ */ o(W, { at: y, items: _, onClose: b }) : null };
227
+ return { onContextMenu: f, onKeyDown: N, menu: y ? /* @__PURE__ */ o(X, { at: y, items: _, onClose: b }) : null };
227
228
  }
228
- function W({
229
+ function X({
229
230
  at: e,
230
231
  items: n,
231
232
  onClose: t
232
233
  }) {
233
- const l = v(null), [m, c] = C(0), i = n.filter((r) => !r.disabled);
234
+ const s = v(null), [m, c] = C(0), l = n.filter((r) => !r.disabled);
234
235
  E(() => {
235
236
  var N;
236
- const r = (s) => {
237
+ const r = (i) => {
237
238
  var d;
238
- (d = l.current) != null && d.contains(s.target) || t();
239
- }, f = (s) => {
240
- if (s.key === "Escape")
241
- s.preventDefault(), t();
242
- else if (s.key === "ArrowDown")
243
- s.preventDefault(), c((d) => (d + 1) % Math.max(1, i.length));
244
- else if (s.key === "ArrowUp")
245
- s.preventDefault(), c((d) => (d - 1 + Math.max(1, i.length)) % Math.max(1, i.length));
246
- else if (s.key === "Enter" || s.key === " ") {
247
- s.preventDefault();
248
- const d = i[m];
239
+ (d = s.current) != null && d.contains(i.target) || t();
240
+ }, f = (i) => {
241
+ if (i.key === "Escape")
242
+ i.preventDefault(), t();
243
+ else if (i.key === "ArrowDown")
244
+ i.preventDefault(), c((d) => (d + 1) % Math.max(1, l.length));
245
+ else if (i.key === "ArrowUp")
246
+ i.preventDefault(), c((d) => (d - 1 + Math.max(1, l.length)) % Math.max(1, l.length));
247
+ else if (i.key === "Enter" || i.key === " ") {
248
+ i.preventDefault();
249
+ const d = l[m];
249
250
  d && (d.run(), t());
250
251
  }
251
252
  };
252
- return window.addEventListener("mousedown", r, !0), window.addEventListener("keydown", f, !0), (N = l.current) == null || N.focus(), () => {
253
+ return window.addEventListener("mousedown", r, !0), window.addEventListener("keydown", f, !0), (N = s.current) == null || N.focus(), () => {
253
254
  window.removeEventListener("mousedown", r, !0), window.removeEventListener("keydown", f, !0);
254
255
  };
255
- }, [t, i, m]);
256
+ }, [t, l, m]);
256
257
  const y = 240, w = n.length * 30 + 12, h = Math.min(e.x, window.innerWidth - y - 8), b = Math.min(e.y, window.innerHeight - w - 8);
257
258
  return J(
258
259
  /* @__PURE__ */ o(
259
260
  "div",
260
261
  {
261
- ref: l,
262
+ ref: s,
262
263
  role: "menu",
263
264
  tabIndex: -1,
264
265
  "data-field-context-menu": !0,
265
266
  style: { position: "fixed", left: h, top: b, width: y, zIndex: 110 },
266
267
  className: "rounded-lg border border-slate-200 bg-white p-1 shadow-xl outline-none dark:border-border dark:bg-card",
267
268
  children: n.map((r) => {
268
- const f = i.indexOf(r), N = f === m && !r.disabled;
269
+ const f = l.indexOf(r), N = f === m && !r.disabled;
269
270
  return /* @__PURE__ */ x(
270
271
  "button",
271
272
  {
@@ -276,7 +277,7 @@ function W({
276
277
  onClick: () => {
277
278
  r.run(), t();
278
279
  },
279
- className: T(
280
+ className: A(
280
281
  "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",
281
282
  N && "bg-accent text-accent-foreground",
282
283
  r.disabled && "cursor-not-allowed opacity-40"
@@ -295,8 +296,8 @@ function W({
295
296
  document.body
296
297
  );
297
298
  }
298
- function ae(e) {
299
- const [n, t] = C(null), [l, m] = C(!1), c = v(!1), i = v(null);
299
+ function ie(e) {
300
+ const [n, t] = C(null), [s, m] = C(!1), c = v(!1), l = v(null);
300
301
  E(() => {
301
302
  const b = e.current;
302
303
  if (!b) return;
@@ -311,32 +312,32 @@ function ae(e) {
311
312
  (b) => {
312
313
  if (!n || c.current) return;
313
314
  const r = b.target;
314
- r.matches('input, textarea, select, [contenteditable="true"], [role="combobox"]') && (i.current = r, setTimeout(() => {
315
+ r.matches('input, textarea, select, [contenteditable="true"], [role="combobox"]') && (l.current = r, setTimeout(() => {
315
316
  c.current || r.blur();
316
317
  }, 0), m(!0));
317
318
  },
318
319
  [n]
319
320
  ), w = g(() => {
320
321
  c.current = !0, m(!1);
321
- const b = i.current;
322
- i.current = null, b && setTimeout(() => b.focus(), 0);
322
+ const b = l.current;
323
+ l.current = null, b && setTimeout(() => b.focus(), 0);
323
324
  }, []), h = g(() => {
324
- m(!1), i.current = null;
325
+ m(!1), l.current = null;
325
326
  }, []);
326
- return { editor: n, confirming: l, onFocusCapture: y, confirm: w, cancel: h };
327
+ return { editor: n, confirming: s, onFocusCapture: y, confirm: w, cancel: h };
327
328
  }
328
- function se({
329
+ function le({
329
330
  editor: e,
330
331
  confirming: n,
331
332
  onConfirm: t,
332
- onCancel: l
333
+ onCancel: s
333
334
  }) {
334
335
  const m = e.split(/\s+/).map((c) => c[0]).filter(Boolean).slice(0, 2).join("").toUpperCase();
335
336
  return /* @__PURE__ */ x(
336
337
  "div",
337
338
  {
338
339
  "data-presence-soft-lock": !0,
339
- className: T(
340
+ className: A(
340
341
  "flex flex-wrap items-center gap-2 rounded-md px-2 py-1 text-[11.5px]",
341
342
  n ? "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"
342
343
  ),
@@ -357,7 +358,7 @@ function se({
357
358
  "button",
358
359
  {
359
360
  type: "button",
360
- onClick: l,
361
+ onClick: s,
361
362
  className: "rounded-md border border-amber-300 px-2 py-0.5 text-[11px] font-medium hover:bg-amber-100 dark:border-amber-500/40 dark:hover:bg-amber-500/15",
362
363
  children: "Leave it"
363
364
  }
@@ -368,11 +369,12 @@ function se({
368
369
  );
369
370
  }
370
371
  export {
371
- R as FieldAffordancesContext,
372
- re as LockReasonBadge,
373
- se as PresenceSoftLockStrip,
374
- ne as RemoteChangeGhost,
375
- te as useFieldAffordances,
376
- oe as useFieldContextMenu,
377
- ae as usePresenceSoftLock
372
+ V as FieldAffordancesContext,
373
+ ae as LockReasonBadge,
374
+ le as PresenceSoftLockStrip,
375
+ oe as RemoteChangeGhost,
376
+ j as ghostText,
377
+ re as useFieldAffordances,
378
+ se as useFieldContextMenu,
379
+ ie as usePresenceSoftLock
378
380
  };