@nivaro/react 0.3.94 → 0.3.96

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.
@@ -1,67 +1,74 @@
1
- import { jsx as s, jsxs as h, Fragment as me } from "react/jsx-runtime";
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
- import { usePersonalDefaultsApi as Fe } from "./usePersonalDefaults.js";
12
- const Me = Ne(null), Ye = () => we(Me), ne = (n) => {
13
- if (n == null || n === "") return "empty";
14
- if (typeof n == "boolean") return n ? "Yes" : "No";
15
- if (typeof n == "object")
1
+ import { jsx as l, jsxs as g, Fragment as fe } from "react/jsx-runtime";
2
+ import { Copy as Z, History as me, 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 R, 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 ee } from "../../lib/utils.js";
8
+ import { useOverflowTip as Ee } from "../TipLayer.js";
9
+ import { clearPersonalDefault as Te, usePersonalDefaultCss as Le, refusalText as te } from "./PersonalDefaultControl.js";
10
+ import { PERSONAL_DEFAULT_GHOST_BUTTON as Ue } from "./PersonalDefaultPill.js";
11
+ import { usePersonalDefaultsApi as Oe } from "./usePersonalDefaults.js";
12
+ import { useRecordLabels as Re } from "./useRecordLabels.js";
13
+ const Fe = ve(null), ze = () => we(Fe), Me = (t) => {
14
+ if (t == null || t === "") return "empty";
15
+ if (typeof t == "boolean") return t ? "Yes" : "No";
16
+ if (typeof t == "object")
16
17
  try {
17
- const l = JSON.stringify(n);
18
- return l.length > 80 ? `${l.slice(0, 80)}…` : l;
18
+ const a = JSON.stringify(t);
19
+ return a.length > 80 ? `${a.slice(0, 80)}…` : a;
19
20
  } catch {
20
- return String(n);
21
+ return String(t);
21
22
  }
22
- const t = String(n), o = /[<&]/.test(t) ? Ee(t).trim() : t;
23
- return o.length > 80 ? `${o.slice(0, 80)}…` : o;
23
+ const n = String(t), s = /[<&]/.test(n) ? Se(n).trim() : n;
24
+ return s.length > 80 ? `${s.slice(0, 80)}…` : s;
24
25
  };
25
- function qe({
26
- change: n,
27
- onDismiss: t,
28
- onTakeTheirs: o
26
+ function Je({
27
+ change: t,
28
+ onDismiss: n,
29
+ onTakeTheirs: s,
30
+ relatedCollection: a
29
31
  }) {
30
- return n.conflict && o ? /* @__PURE__ */ h(
32
+ const d = Re(
33
+ a,
34
+ [t.was, t.theirs],
35
+ !!a
36
+ ), f = (b) => b != null && typeof b != "object" && d.has(String(b)) ? d.get(String(b)) : Me(b);
37
+ return t.conflict && s ? /* @__PURE__ */ g(
31
38
  "div",
32
39
  {
33
40
  "data-remote-change-ghost": !0,
34
41
  "data-remote-conflict": !0,
35
42
  className: "nvr-expand-in flex flex-wrap items-center gap-1.5 rounded-md border border-amber-300 bg-amber-50 px-2 py-1 text-[11.5px] text-amber-900 dark:border-amber-500/40 dark:bg-amber-500/10 dark:text-amber-100",
36
43
  children: [
37
- /* @__PURE__ */ s("span", { className: "h-1.5 w-1.5 shrink-0 animate-pulse rounded-full bg-amber-500" }),
38
- /* @__PURE__ */ h("span", { className: "min-w-0 flex-1", children: [
39
- n.by ?? "Someone",
44
+ /* @__PURE__ */ l("span", { className: "h-1.5 w-1.5 shrink-0 animate-pulse rounded-full bg-amber-500" }),
45
+ /* @__PURE__ */ g("span", { className: "min-w-0 flex-1", children: [
46
+ t.by ?? "Someone",
40
47
  " changed this to",
41
48
  " ",
42
- /* @__PURE__ */ s("span", { className: "font-medium", children: ne(n.theirs) }),
49
+ /* @__PURE__ */ l("span", { className: "font-medium", children: f(t.theirs) }),
43
50
  " while you were editing",
44
- /* @__PURE__ */ h("span", { className: "text-amber-700/80 dark:text-amber-200/70", children: [
51
+ /* @__PURE__ */ g("span", { className: "text-amber-700/80 dark:text-amber-200/70", children: [
45
52
  " ",
46
53
  "· ",
47
- ee(n.at)
54
+ ee(t.at)
48
55
  ] })
49
56
  ] }),
50
- /* @__PURE__ */ s(
57
+ /* @__PURE__ */ l(
51
58
  "button",
52
59
  {
53
60
  type: "button",
54
- onClick: o,
61
+ onClick: s,
55
62
  "data-remote-take-theirs": !0,
56
63
  className: "shrink-0 rounded border border-amber-400 bg-white px-1.5 py-0.5 text-[10.5px] font-medium text-amber-900 hover:bg-amber-100 dark:bg-transparent dark:text-amber-100 dark:hover:bg-amber-500/20",
57
64
  children: "Take theirs"
58
65
  }
59
66
  ),
60
- /* @__PURE__ */ s(
67
+ /* @__PURE__ */ l(
61
68
  "button",
62
69
  {
63
70
  type: "button",
64
- onClick: t,
71
+ onClick: n,
65
72
  "data-remote-keep-mine": !0,
66
73
  className: "shrink-0 rounded px-1.5 py-0.5 text-[10.5px] font-medium text-amber-800 hover:bg-amber-100 dark:text-amber-200 dark:hover:bg-amber-500/20",
67
74
  children: "Keep mine"
@@ -69,218 +76,218 @@ function qe({
69
76
  )
70
77
  ]
71
78
  }
72
- ) : /* @__PURE__ */ h(
79
+ ) : /* @__PURE__ */ g(
73
80
  "div",
74
81
  {
75
82
  "data-remote-change-ghost": !0,
76
83
  className: "nvr-expand-in flex items-start gap-1.5 rounded-md border border-sky-200 bg-sky-50 px-2 py-1 text-[11.5px] text-sky-900 dark:border-sky-500/30 dark:bg-sky-500/10 dark:text-sky-200",
77
84
  children: [
78
- /* @__PURE__ */ s("span", { className: "mt-0.5 h-1.5 w-1.5 shrink-0 animate-pulse rounded-full bg-sky-500" }),
79
- /* @__PURE__ */ h("span", { className: "min-w-0 flex-1", children: [
85
+ /* @__PURE__ */ l("span", { className: "mt-0.5 h-1.5 w-1.5 shrink-0 animate-pulse rounded-full bg-sky-500" }),
86
+ /* @__PURE__ */ g("span", { className: "min-w-0 flex-1", children: [
80
87
  "was",
81
88
  " ",
82
- /* @__PURE__ */ s("span", { className: "font-medium line-through decoration-sky-400/70", children: ne(n.was) }),
83
- /* @__PURE__ */ h("span", { className: "text-sky-700/80 dark:text-sky-300/80", children: [
89
+ /* @__PURE__ */ l("span", { className: "font-medium line-through decoration-sky-400/70", children: f(t.was) }),
90
+ /* @__PURE__ */ g("span", { className: "text-sky-700/80 dark:text-sky-300/80", children: [
84
91
  " ",
85
92
  "· ",
86
- n.by ?? "someone",
93
+ t.by ?? "someone",
87
94
  ", ",
88
- ee(n.at)
95
+ ee(t.at)
89
96
  ] })
90
97
  ] }),
91
- /* @__PURE__ */ s(
98
+ /* @__PURE__ */ l(
92
99
  "button",
93
100
  {
94
101
  type: "button",
95
- onClick: t,
102
+ onClick: n,
96
103
  "aria-label": "Dismiss",
97
104
  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(re, { className: "h-3 w-3" })
105
+ children: /* @__PURE__ */ l(ne, { className: "h-3 w-3" })
99
106
  }
100
107
  )
101
108
  ]
102
109
  }
103
110
  );
104
111
  }
105
- function ze({ reason: n, onHover: t }) {
106
- return /* @__PURE__ */ s(
112
+ function Qe({ reason: t, onHover: n }) {
113
+ return /* @__PURE__ */ l(
107
114
  "span",
108
115
  {
109
- onPointerEnter: t,
116
+ onPointerEnter: n,
110
117
  className: "inline-flex cursor-help items-center gap-1 text-amber-500 dark:text-amber-400",
111
- "data-tip": n,
118
+ "data-tip": t,
112
119
  "data-lock-reason": !0,
113
- "aria-label": n,
120
+ "aria-label": t,
114
121
  role: "img",
115
- children: /* @__PURE__ */ s(ve, { className: "h-3 w-3" })
122
+ children: /* @__PURE__ */ l(ke, { className: "h-3 w-3" })
116
123
  }
117
124
  );
118
125
  }
119
- function Re(n, t) {
120
- if (!n || !(t != null && t.contains(n))) return null;
121
- const o = n.closest(
126
+ function $e(t, n) {
127
+ if (!t || !(n != null && n.contains(t))) return null;
128
+ const s = t.closest(
122
129
  "input, textarea, select"
123
130
  );
124
- if (o && t.contains(o) && !(o instanceof HTMLInputElement && o.type === "checkbox"))
125
- return o.value;
126
- const l = n.closest("td, th");
127
- return l && t.contains(l) ? l.innerText.replace(/\s+/g, " ").trim() : null;
131
+ if (s && n.contains(s) && !(s instanceof HTMLInputElement && s.type === "checkbox"))
132
+ return s.value;
133
+ const a = t.closest("td, th");
134
+ return a && n.contains(a) ? a.innerText.replace(/\s+/g, " ").trim() : null;
128
135
  }
129
- function Je({
130
- wrapperRef: n,
131
- field: t,
132
- value: o,
133
- relations: l,
134
- collection: m,
135
- itemId: x,
136
- openRelated: v,
137
- editable: M = !1
136
+ function Ze({
137
+ wrapperRef: t,
138
+ field: n,
139
+ value: s,
140
+ relations: a,
141
+ collection: d,
142
+ itemId: f,
143
+ openRelated: b,
144
+ editable: F = !1
138
145
  }) {
139
146
  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
- var u;
145
- document.activeElement && document.activeElement !== document.body || (e != null && e.isConnected ? e.focus() : (u = c == null ? void 0 : c()) == null || u.focus());
147
+ const [k, T] = C(null), r = Oe(), [w, S] = C(!1), [h, $] = C(null), [L, j] = C(null), [M, A] = C(!1), x = N((e, c) => T({ x: e, y: c }), []), [D, o] = C(null), p = R(null), U = R(null), i = N(() => {
148
+ T(null), o(null), S(!1), $(null), j(null), A(!1);
149
+ const e = p.current, c = U.current;
150
+ p.current = null, U.current = null, (e || c) && window.setTimeout(() => {
151
+ var m;
152
+ document.activeElement && document.activeElement !== document.body || (e != null && e.isConnected ? e.focus() : (m = c == null ? void 0 : c()) == null || m.focus());
146
153
  }, 0);
147
- }, []), p = g !== null, d = N(
154
+ }, []), y = k !== null, u = N(
148
155
  (e) => {
149
- if (p) {
156
+ if (y) {
150
157
  i();
151
158
  return;
152
159
  }
153
160
  const c = e.getBoundingClientRect();
154
- _.current = null, f.current = e, a("menu"), b(c.left, c.bottom + 4);
161
+ _.current = null, p.current = e, o("menu"), x(c.left, c.bottom + 4);
155
162
  },
156
- [p, i, b]
163
+ [y, i, x]
157
164
  ), E = N(() => {
158
- r && ($(null), S("save"), r.describeSave(t.field).then(
165
+ r && ($(null), S("save"), r.describeSave(n.field).then(
159
166
  (e) => $(e),
160
167
  () => $([])
161
168
  ));
162
- }, [r, t.field]), P = N(() => {
163
- r && (A(null), S("update"), r.describeUpdate(t.field).then(
164
- (e) => A(e),
165
- () => A({ value: "", context: [] })
169
+ }, [r, n.field]), P = N(() => {
170
+ r && (j(null), S("update"), r.describeUpdate(n.field).then(
171
+ (e) => j(e),
172
+ () => j({ value: "", context: [] })
166
173
  ));
167
- }, [r, t.field]), H = N(
168
- (e, c, u = "make") => {
169
- if (p && D === u) {
174
+ }, [r, n.field]), H = N(
175
+ (e, c, m = "make") => {
176
+ if (y && D === m) {
170
177
  i();
171
178
  return;
172
179
  }
173
180
  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);
181
+ _.current = null, p.current = e, U.current = c ?? null, o(m), m === "update" ? P() : E(), x(O.right - ae, O.bottom + 4);
175
182
  },
176
- [p, D, i, b, E, P]
177
- ), _ = F(null), le = N(
183
+ [y, D, i, x, E, P]
184
+ ), _ = R(null), oe = N(
178
185
  (e) => {
179
186
  var O;
180
187
  const c = e.target;
181
- (O = window.getSelection()) != null && O.toString() && c.closest("input, textarea, [contenteditable]") || (e.preventDefault(), _.current = c, a("menu"), b(e.clientX, e.clientY));
188
+ (O = window.getSelection()) != null && O.toString() && c.closest("input, textarea, [contenteditable]") || (e.preventDefault(), _.current = c, o("menu"), x(e.clientX, e.clientY));
182
189
  },
183
- [b]
190
+ [x]
184
191
  ), se = N(
185
192
  (e) => {
186
193
  var c;
187
194
  if (e.key === "ContextMenu" || e.shiftKey && e.key === "F10") {
188
195
  e.preventDefault();
189
- const u = (c = n.current) == null ? void 0 : c.getBoundingClientRect();
190
- _.current = document.activeElement, a("menu"), b(u ? u.left + 16 : 16, u ? u.top + 28 : 16);
196
+ const m = (c = t.current) == null ? void 0 : c.getBoundingClientRect();
197
+ _.current = document.activeElement, o("menu"), x(m ? m.left + 16 : 16, m ? m.top + 28 : 16);
191
198
  }
192
199
  },
193
- [b, n]
194
- ), I = l.find(
195
- (e) => e.many_collection === m && e.many_field === t.field && e.one_collection
196
- ), K = x && x !== "new", W = (e) => {
197
- var u;
198
- const c = (u = n.current) == null ? void 0 : u.querySelector(e);
200
+ [x, t]
201
+ ), I = a.find(
202
+ (e) => e.many_collection === d && e.many_field === n.field && e.one_collection
203
+ ), K = f && f !== "new", W = (e) => {
204
+ var m;
205
+ const c = (m = t.current) == null ? void 0 : m.querySelector(e);
199
206
  return c ? (c.click(), !0) : !1;
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 = [
207
+ }, X = !!(r != null && r.allowed(n.field)) && r.manageable(n.field), Y = X && F && !!(r != null && r.hasValue(n.field)), G = X ? (r == null ? void 0 : r.defaultFor(n.field)) ?? null : null, le = Y && !G, ie = Y && !!G && !(r != null && r.isDefault(n.field)), q = [
201
208
  {
202
209
  key: "copy",
203
210
  label: "Copy value",
204
- icon: /* @__PURE__ */ s(Z, { className: "h-3.5 w-3.5" }),
211
+ icon: /* @__PURE__ */ l(Z, { className: "h-3.5 w-3.5" }),
205
212
  run: () => {
206
- const c = Re(_.current, n.current) ?? (o == null ? "" : typeof o == "object" ? JSON.stringify(o) : String(o));
213
+ const c = $e(_.current, t.current) ?? (s == null ? "" : typeof s == "object" ? JSON.stringify(s) : String(s));
207
214
  if (!c) {
208
- w.info("Nothing to copy");
215
+ v.info("Nothing to copy");
209
216
  return;
210
217
  }
211
218
  navigator.clipboard.writeText(c).then(
212
- () => w.success("Value copied"),
213
- () => w.error("Could not copy")
219
+ () => v.success("Value copied"),
220
+ () => v.error("Could not copy")
214
221
  );
215
222
  }
216
223
  },
217
224
  {
218
225
  key: "copy-key",
219
226
  label: "Copy field key",
220
- icon: /* @__PURE__ */ s(Z, { className: "h-3.5 w-3.5" }),
221
- hint: t.field,
227
+ icon: /* @__PURE__ */ l(Z, { className: "h-3.5 w-3.5" }),
228
+ hint: n.field,
222
229
  run: () => {
223
- navigator.clipboard.writeText(t.field).then(
224
- () => w.success(`Copied “${t.field}”`),
225
- () => w.error("Could not copy")
230
+ navigator.clipboard.writeText(n.field).then(
231
+ () => v.success(`Copied “${n.field}”`),
232
+ () => v.error("Could not copy")
226
233
  );
227
234
  }
228
235
  },
229
236
  {
230
237
  key: "history",
231
238
  label: "Value history",
232
- icon: /* @__PURE__ */ s(be, { className: "h-3.5 w-3.5" }),
239
+ icon: /* @__PURE__ */ l(me, { className: "h-3.5 w-3.5" }),
233
240
  disabled: !K,
234
241
  run: () => {
235
- W("[data-field-history]") || w.info("No history for this field yet");
242
+ W("[data-field-history]") || v.info("No history for this field yet");
236
243
  }
237
244
  },
238
245
  {
239
246
  key: "watch",
240
247
  label: "Watch this field",
241
- icon: /* @__PURE__ */ s(pe, { className: "h-3.5 w-3.5" }),
248
+ icon: /* @__PURE__ */ l(be, { className: "h-3.5 w-3.5" }),
242
249
  disabled: !K,
243
250
  run: () => {
244
- W("[data-field-watch]") || w.info("Field watching is off — an admin can enable it in Settings → Content");
251
+ W("[data-field-watch]") || v.info("Field watching is off — an admin can enable it in Settings → Content");
245
252
  }
246
253
  },
247
254
  {
248
255
  key: "explain",
249
256
  label: "Explain value",
250
- icon: /* @__PURE__ */ s(xe, { className: "h-3.5 w-3.5" }),
251
- disabled: !K || !((J = n.current) != null && J.querySelector("[data-field-lineage]")),
257
+ icon: /* @__PURE__ */ l(pe, { className: "h-3.5 w-3.5" }),
258
+ disabled: !K || !((J = t.current) != null && J.querySelector("[data-field-lineage]")),
252
259
  run: () => {
253
260
  W("[data-field-lineage]");
254
261
  }
255
262
  },
256
- ...I && v ? [
263
+ ...I && b ? [
257
264
  {
258
265
  key: "open",
259
266
  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
- disabled: o == null || o === "",
267
+ icon: /* @__PURE__ */ l(xe, { className: "h-3.5 w-3.5" }),
268
+ disabled: s == null || s === "",
262
269
  run: () => {
263
- const e = typeof o == "object" && o && "id" in o ? String(o.id) : String(o);
264
- v(String(I.one_collection), e);
270
+ const e = typeof s == "object" && s && "id" in s ? String(s.id) : String(s);
271
+ b(String(I.one_collection), e);
265
272
  }
266
273
  }
267
274
  ] : [],
268
275
  // Same states as the visible control: no default here → Save; a default holding another
269
276
  // value → Update (that default, in place); the value IS the default → only Clear.
270
- ...ie ? [
277
+ ...le ? [
271
278
  {
272
279
  key: "save-default",
273
280
  label: "Save as my default",
274
- icon: /* @__PURE__ */ s(he, { className: "h-3.5 w-3.5" }),
281
+ icon: /* @__PURE__ */ l(ye, { className: "h-3.5 w-3.5" }),
275
282
  stay: !0,
276
283
  run: E
277
284
  }
278
285
  ] : [],
279
- ...ce ? [
286
+ ...ie ? [
280
287
  {
281
288
  key: "update-default",
282
289
  label: "Update my default",
283
- icon: /* @__PURE__ */ s(ge, { className: "h-3.5 w-3.5" }),
290
+ icon: /* @__PURE__ */ l(he, { className: "h-3.5 w-3.5" }),
284
291
  stay: !0,
285
292
  run: P
286
293
  }
@@ -289,294 +296,294 @@ function Je({
289
296
  {
290
297
  key: "clear-default",
291
298
  label: "Clear my default",
292
- icon: /* @__PURE__ */ s(ke, { className: "h-3.5 w-3.5" }),
299
+ icon: /* @__PURE__ */ l(ge, { className: "h-3.5 w-3.5" }),
293
300
  // Runs at once (a menu pick is deliberate); the toast's Undo saves it back.
294
301
  run: () => {
295
- Ue(r, t.field);
302
+ Te(r, n.field);
296
303
  }
297
304
  }
298
305
  ] : []
299
306
  ], 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 ? {
307
+ const m = e.value ? ` to ${e.value}` : "", O = e.context.length ? ` for ${e.context.join(" · ")}` : "";
308
+ return c ? `Updated your default${O}${m}` : `Update your default${O}${m}?`;
309
+ }, ce = w === "update" && r ? {
303
310
  label: "Update my default",
304
311
  action: "Update",
305
- text: U ? z(U, !1) : "Update your default?",
306
- ready: U !== null && !R,
307
- saving: R,
312
+ text: L ? z(L, !1) : "Update your default?",
313
+ ready: L !== null && !M,
314
+ saving: M,
308
315
  onCancel: i,
309
316
  onSave: () => {
310
- j(!0), r.update(t.field).then(
317
+ A(!0), r.update(n.field).then(
311
318
  () => {
312
- w.success(U ? z(U, !0) : "Updated your default"), i();
319
+ v.success(L ? z(L, !0) : "Updated your default"), i();
313
320
  },
314
321
  (e) => {
315
- w.error(te(e, "Could not update your default")), i();
322
+ v.error(te(e, "Could not update your default")), i();
316
323
  }
317
324
  );
318
325
  }
319
- } : k && r ? {
326
+ } : w && r ? {
320
327
  label: "Save as my default",
321
328
  action: "Save",
322
- text: y != null && y.length ? `Save ${y.join(" · ")} as your ${y.length > 1 ? "defaults" : "default"}?` : "Save as your default?",
323
- ready: y !== null && !R,
324
- saving: R,
329
+ text: h != null && h.length ? `Save ${h.join(" · ")} as your ${h.length > 1 ? "defaults" : "default"}?` : "Save as your default?",
330
+ ready: h !== null && !M,
331
+ saving: M,
325
332
  onCancel: i,
326
333
  onSave: () => {
327
- j(!0), r.save(t.field).then(
334
+ A(!0), r.save(n.field).then(
328
335
  () => {
329
- w.success(
330
- y != null && y.length ? `Saved ${y.join(" · ")} as your default${y.length > 1 ? "s" : ""}` : "Your default was saved"
336
+ v.success(
337
+ h != null && h.length ? `Saved ${h.join(" · ")} as your default${h.length > 1 ? "s" : ""}` : "Your default was saved"
331
338
  ), i();
332
339
  },
333
340
  (e) => {
334
- w.error(te(e, "Could not save your default")), i();
341
+ v.error(te(e, "Could not save your default")), i();
335
342
  }
336
343
  );
337
344
  }
338
- } : null, ue = g ? /* @__PURE__ */ s(
345
+ } : null, de = k ? /* @__PURE__ */ l(
339
346
  Ae,
340
347
  {
341
- at: g,
348
+ at: k,
342
349
  items: q,
343
350
  onClose: i,
344
- confirm: de,
345
- anchor: n.current
351
+ confirm: ce,
352
+ anchor: t.current
346
353
  }
347
- ) : null, fe = q.some(
354
+ ) : null, ue = q.some(
348
355
  (e) => e.key === "save-default" || e.key === "update-default" || e.key === "clear-default"
349
356
  );
350
357
  return {
351
- onContextMenu: le,
358
+ onContextMenu: oe,
352
359
  onKeyDown: se,
353
- menu: ue,
354
- openFrom: d,
355
- isOpen: p,
356
- hasFieldItems: fe,
360
+ menu: de,
361
+ openFrom: u,
362
+ isOpen: y,
363
+ hasFieldItems: ue,
357
364
  confirmSaveFrom: H,
358
365
  openedBy: D
359
366
  };
360
367
  }
361
- const oe = 240, $e = "[data-field-menu-trigger], [data-personal-default-make], [data-personal-default-update]";
368
+ const ae = 240, je = "[data-field-menu-trigger], [data-personal-default-make], [data-personal-default-update]";
362
369
  function Ae({
363
- at: n,
364
- items: t,
365
- onClose: o,
366
- confirm: l,
367
- anchor: m
370
+ at: t,
371
+ items: n,
372
+ onClose: s,
373
+ confirm: a,
374
+ anchor: d
368
375
  }) {
369
376
  Le();
370
- const x = F(null), [v, M] = C(0), g = t.filter((a) => !a.disabled);
377
+ const f = R(null), [b, F] = C(0), k = n.filter((o) => !o.disabled);
371
378
  B(() => {
372
- var L;
373
- const a = (i) => {
374
- var d, E;
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) && (m != null && m.contains(p)) || o();
377
- }, f = (i) => {
378
- var p;
379
+ var U;
380
+ const o = (i) => {
381
+ var u, E;
382
+ const y = i.target;
383
+ (u = f.current) != null && u.contains(y) || (E = y == null ? void 0 : y.closest) != null && E.call(y, je) && (d != null && d.contains(y)) || s();
384
+ }, p = (i) => {
385
+ var y;
379
386
  if (i.key === "Escape")
380
- i.preventDefault(), o();
381
- else if (l) {
387
+ i.preventDefault(), s();
388
+ else if (a) {
382
389
  if (i.key === "Tab") {
383
390
  i.preventDefault();
384
- const d = [r.current, T.current].filter(
391
+ const u = [r.current, T.current].filter(
385
392
  (H) => !!H && !H.disabled
386
393
  );
387
- if (d.length === 0) return;
388
- const E = d.indexOf(document.activeElement), P = i.shiftKey ? E - 1 : E + 1;
389
- (p = d[(P % d.length + d.length) % d.length]) == null || p.focus();
394
+ if (u.length === 0) return;
395
+ const E = u.indexOf(document.activeElement), P = i.shiftKey ? E - 1 : E + 1;
396
+ (y = u[(P % u.length + u.length) % u.length]) == null || y.focus();
390
397
  }
391
398
  return;
392
399
  } else if (i.key === "ArrowDown")
393
- i.preventDefault(), M((d) => (d + 1) % Math.max(1, g.length));
400
+ i.preventDefault(), F((u) => (u + 1) % Math.max(1, k.length));
394
401
  else if (i.key === "ArrowUp")
395
- i.preventDefault(), M((d) => (d - 1 + Math.max(1, g.length)) % Math.max(1, g.length));
402
+ i.preventDefault(), F((u) => (u - 1 + Math.max(1, k.length)) % Math.max(1, k.length));
396
403
  else if (i.key === "Enter" || i.key === " ") {
397
404
  i.preventDefault();
398
- const d = g[v];
399
- d && (d.run(), d.stay || o());
405
+ const u = k[b];
406
+ u && (u.run(), u.stay || s());
400
407
  }
401
408
  };
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);
409
+ return window.addEventListener("mousedown", o, !0), window.addEventListener("keydown", p, !0), (U = f.current) == null || U.focus(), () => {
410
+ window.removeEventListener("mousedown", o, !0), window.removeEventListener("keydown", p, !0);
404
411
  };
405
- }, [o, g, v, l, m]);
406
- const T = F(null), r = F(null), k = !!l, S = !!(l != null && l.ready);
412
+ }, [s, k, b, a, d]);
413
+ const T = R(null), r = R(null), w = !!a, S = !!(a != null && a.ready);
407
414
  B(() => {
408
- var a;
409
- k && ((a = r.current) == null || a.focus());
410
- }, [k]), B(() => {
411
- var f;
415
+ var o;
416
+ w && ((o = r.current) == null || o.focus());
417
+ }, [w]), B(() => {
418
+ var p;
412
419
  if (!S) return;
413
- const a = document.activeElement;
414
- (a === r.current || a === x.current || a === document.body) && ((f = T.current) == null || f.focus());
420
+ const o = document.activeElement;
421
+ (o === r.current || o === f.current || o === document.body) && ((p = T.current) == null || p.focus());
415
422
  }, [S]);
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
- a && a !== U && A(a);
423
+ const h = Math.min(ae, window.innerWidth - 16), $ = Ee(a == null ? void 0 : a.text), [L, j] = C(() => a ? 96 : n.length * 30 + 12);
424
+ Ne(() => {
425
+ var p;
426
+ const o = (p = f.current) == null ? void 0 : p.offsetHeight;
427
+ o && o !== L && j(o);
421
428
  });
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
- const a = b.getBoundingClientRect();
429
+ const M = Math.max(8, Math.min(t.x, window.innerWidth - h - 8)), A = Math.max(8, Math.min(t.y, window.innerHeight - L - 8)), x = (d == null ? void 0 : d.closest('[role="dialog"]')) ?? document.body, D = x === document.body ? { position: "fixed", left: M, top: A } : (() => {
430
+ const o = x.getBoundingClientRect();
424
431
  return {
425
432
  position: "absolute",
426
- left: R - a.left + b.scrollLeft - b.clientLeft,
427
- top: j - a.top + b.scrollTop - b.clientTop
433
+ left: M - o.left + x.scrollLeft - x.clientLeft,
434
+ top: A - o.top + x.scrollTop - x.clientTop
428
435
  };
429
436
  })();
430
- return Se(
431
- /* @__PURE__ */ h(
437
+ return Ce(
438
+ /* @__PURE__ */ g(
432
439
  "div",
433
440
  {
434
- ref: x,
435
- ...l ? { role: "dialog", "aria-modal": !1, "aria-label": l.label } : { role: "menu", "aria-label": "Field options" },
441
+ ref: f,
442
+ ...a ? { role: "dialog", "aria-modal": !1, "aria-label": a.label } : { role: "menu", "aria-label": "Field options" },
436
443
  tabIndex: -1,
437
444
  "data-field-context-menu": !0,
438
- style: { ...D, width: y, maxWidth: "calc(100vw - 16px)", zIndex: 110 },
445
+ style: { ...D, width: h, maxWidth: "calc(100vw - 16px)", zIndex: 110 },
439
446
  className: "rounded-lg border border-slate-200 bg-white p-1 shadow-xl outline-none dark:border-border dark:bg-card",
440
447
  children: [
441
- l ? /* @__PURE__ */ h("div", { "data-personal-default-confirm": !0, className: "space-y-2 px-2 py-1.5", children: [
442
- /* @__PURE__ */ s(
448
+ a ? /* @__PURE__ */ g("div", { "data-personal-default-confirm": !0, className: "space-y-2 px-2 py-1.5", children: [
449
+ /* @__PURE__ */ l(
443
450
  "p",
444
451
  {
445
452
  ref: $,
446
453
  "aria-live": "polite",
447
454
  className: "line-clamp-4 text-[12.5px] leading-snug text-slate-700 [overflow-wrap:anywhere] dark:text-slate-200",
448
- children: l.text
455
+ children: a.text
449
456
  }
450
457
  ),
451
- /* @__PURE__ */ h("div", { className: "flex justify-end gap-1.5", children: [
452
- /* @__PURE__ */ h(
458
+ /* @__PURE__ */ g("div", { className: "flex justify-end gap-1.5", children: [
459
+ /* @__PURE__ */ g(
453
460
  "button",
454
461
  {
455
462
  ref: r,
456
463
  type: "button",
457
- onClick: l.onCancel,
458
- className: Oe,
464
+ onClick: a.onCancel,
465
+ className: Ue,
459
466
  children: [
460
- /* @__PURE__ */ s(re, { className: "h-3 w-3", "aria-hidden": !0 }),
467
+ /* @__PURE__ */ l(ne, { className: "h-3 w-3", "aria-hidden": !0 }),
461
468
  " Cancel"
462
469
  ]
463
470
  }
464
471
  ),
465
- /* @__PURE__ */ s(
472
+ /* @__PURE__ */ l(
466
473
  "button",
467
474
  {
468
475
  ref: T,
469
476
  type: "button",
470
- disabled: !l.ready,
471
- onClick: l.onSave,
477
+ disabled: !a.ready,
478
+ onClick: a.onSave,
472
479
  className: "h-7 rounded-md bg-nvr-cyan px-2.5 text-[11.5px] font-semibold text-white hover:bg-nvr-cyan/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/40 focus-visible:ring-offset-1 disabled:cursor-not-allowed disabled:opacity-50",
473
- children: l.saving ? "Saving…" : l.action
480
+ children: a.saving ? "Saving…" : a.action
474
481
  }
475
482
  )
476
483
  ] })
477
484
  ] }) : null,
478
- l ? null : t.map((a) => {
479
- const f = g.indexOf(a), L = f === v && !a.disabled;
480
- return /* @__PURE__ */ h(
485
+ a ? null : n.map((o) => {
486
+ const p = k.indexOf(o), U = p === b && !o.disabled;
487
+ return /* @__PURE__ */ g(
481
488
  "button",
482
489
  {
483
490
  type: "button",
484
491
  role: "menuitem",
485
- disabled: a.disabled,
486
- onMouseEnter: () => f >= 0 && M(f),
492
+ disabled: o.disabled,
493
+ onMouseEnter: () => p >= 0 && F(p),
487
494
  onClick: () => {
488
- a.run(), a.stay || o();
495
+ o.run(), o.stay || s();
489
496
  },
490
- className: ae(
497
+ className: re(
491
498
  "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
- L && "bg-accent text-accent-foreground",
493
- a.disabled && "cursor-not-allowed opacity-40"
499
+ U && "bg-accent text-accent-foreground",
500
+ o.disabled && "cursor-not-allowed opacity-40"
494
501
  ),
495
502
  children: [
496
- /* @__PURE__ */ s("span", { className: "shrink-0 text-slate-500", children: a.icon }),
497
- /* @__PURE__ */ s("span", { className: "min-w-0 flex-1 truncate", children: a.label }),
498
- a.hint && /* @__PURE__ */ s("span", { className: "max-w-[90px] truncate font-mono text-[10.5px] text-slate-400", children: a.hint })
503
+ /* @__PURE__ */ l("span", { className: "shrink-0 text-slate-500", children: o.icon }),
504
+ /* @__PURE__ */ l("span", { className: "min-w-0 flex-1 truncate", children: o.label }),
505
+ o.hint && /* @__PURE__ */ l("span", { className: "max-w-[90px] truncate font-mono text-[10.5px] text-slate-400", children: o.hint })
499
506
  ]
500
507
  },
501
- a.key
508
+ o.key
502
509
  );
503
510
  })
504
511
  ]
505
512
  }
506
513
  ),
507
- b
514
+ x
508
515
  );
509
516
  }
510
517
  const V = /* @__PURE__ */ new Set();
511
- function Qe(n, t) {
512
- t ? V.add(n) : V.delete(n);
518
+ function et(t, n) {
519
+ n ? V.add(t) : V.delete(t);
513
520
  }
514
- function je() {
521
+ function De() {
515
522
  return V.size > 0;
516
523
  }
517
- function Ze(n) {
518
- const [t, o] = C(null), [l, m] = C(!1), x = F(!1), v = F(null);
524
+ function tt(t) {
525
+ const [n, s] = C(null), [a, d] = C(!1), f = R(!1), b = R(null);
519
526
  B(() => {
520
- const r = n.current;
527
+ const r = t.current;
521
528
  if (!r) return;
522
- const k = () => o(r.getAttribute("data-remote-editor"));
523
- k();
524
- const S = new MutationObserver(k);
529
+ const w = () => s(r.getAttribute("data-remote-editor"));
530
+ w();
531
+ const S = new MutationObserver(w);
525
532
  return S.observe(r, { attributes: !0, attributeFilter: ["data-remote-editor"] }), () => S.disconnect();
526
- }, [n]), B(() => {
527
- t || (m(!1), x.current = !1);
528
- }, [t]);
529
- const M = N(
533
+ }, [t]), B(() => {
534
+ n || (d(!1), f.current = !1);
535
+ }, [n]);
536
+ const F = N(
530
537
  (r) => {
531
- if (!t || x.current || je()) return;
532
- const k = r.target;
533
- k.matches('input, textarea, select, [contenteditable="true"], [role="combobox"]') && (v.current = k, setTimeout(() => {
534
- x.current || k.blur();
535
- }, 0), m(!0));
538
+ if (!n || f.current || De()) return;
539
+ const w = r.target;
540
+ w.matches('input, textarea, select, [contenteditable="true"], [role="combobox"]') && (b.current = w, setTimeout(() => {
541
+ f.current || w.blur();
542
+ }, 0), d(!0));
536
543
  },
537
- [t]
538
- ), g = N(() => {
539
- x.current = !0, m(!1);
540
- const r = v.current;
541
- v.current = null, r && setTimeout(() => r.focus(), 0);
544
+ [n]
545
+ ), k = N(() => {
546
+ f.current = !0, d(!1);
547
+ const r = b.current;
548
+ b.current = null, r && setTimeout(() => r.focus(), 0);
542
549
  }, []), T = N(() => {
543
- m(!1), v.current = null;
550
+ d(!1), b.current = null;
544
551
  }, []);
545
- return { editor: t, confirming: l, onFocusCapture: M, confirm: g, cancel: T };
552
+ return { editor: n, confirming: a, onFocusCapture: F, confirm: k, cancel: T };
546
553
  }
547
- function et({
548
- editor: n,
549
- confirming: t,
550
- onConfirm: o,
551
- onCancel: l
554
+ function nt({
555
+ editor: t,
556
+ confirming: n,
557
+ onConfirm: s,
558
+ onCancel: a
552
559
  }) {
553
- const m = n.split(/\s+/).map((x) => x[0]).filter(Boolean).slice(0, 2).join("").toUpperCase();
554
- return /* @__PURE__ */ h(
560
+ const d = t.split(/\s+/).map((f) => f[0]).filter(Boolean).slice(0, 2).join("").toUpperCase();
561
+ return /* @__PURE__ */ g(
555
562
  "div",
556
563
  {
557
564
  "data-presence-soft-lock": !0,
558
- className: ae(
565
+ className: re(
559
566
  "flex flex-wrap items-center gap-2 rounded-md px-2 py-1 text-[11.5px]",
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"
567
+ 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"
561
568
  ),
562
569
  children: [
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 || "?" }),
564
- /* @__PURE__ */ s("span", { className: "min-w-0 flex-1", children: t ? `${n} is typing here — edit anyway?` : `${n} is editing this field` }),
565
- t && /* @__PURE__ */ h(me, { children: [
566
- /* @__PURE__ */ s(
570
+ /* @__PURE__ */ l("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: d || "?" }),
571
+ /* @__PURE__ */ l("span", { className: "min-w-0 flex-1", children: n ? `${t} is typing here — edit anyway?` : `${t} is editing this field` }),
572
+ n && /* @__PURE__ */ g(fe, { children: [
573
+ /* @__PURE__ */ l(
567
574
  "button",
568
575
  {
569
576
  type: "button",
570
- onClick: o,
577
+ onClick: s,
571
578
  className: "rounded-md bg-amber-600 px-2 py-0.5 text-[11px] font-semibold text-white hover:bg-amber-700",
572
579
  children: "Edit anyway"
573
580
  }
574
581
  ),
575
- /* @__PURE__ */ s(
582
+ /* @__PURE__ */ l(
576
583
  "button",
577
584
  {
578
585
  type: "button",
579
- onClick: l,
586
+ onClick: a,
580
587
  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",
581
588
  children: "Leave it"
582
589
  }
@@ -587,14 +594,14 @@ function et({
587
594
  );
588
595
  }
589
596
  export {
590
- Me as FieldAffordancesContext,
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
597
+ Fe as FieldAffordancesContext,
598
+ Qe as LockReasonBadge,
599
+ nt as PresenceSoftLockStrip,
600
+ Je as RemoteChangeGhost,
601
+ Me as ghostText,
602
+ De as holdsLockByTakeOver,
603
+ et as noteTakeOverHold,
604
+ ze as useFieldAffordances,
605
+ Ze as useFieldContextMenu,
606
+ tt as usePresenceSoftLock
600
607
  };