@nivaro/react 0.3.33 → 0.3.35

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 (32) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +79 -5
  4. package/dist/index.js +338 -329
  5. package/dist/shared/components/ItemEditForm.js +5274 -5069
  6. package/dist/shared/components/ProfileView.js +46 -44
  7. package/dist/shared/components/ReportView.js +208 -205
  8. package/dist/shared/components/SearchHighlight.js +30 -0
  9. package/dist/shared/components/TipLayer.js +39 -37
  10. package/dist/shared/components/item-edit/CatalogPickerField.js +1484 -1232
  11. package/dist/shared/components/item-edit/FieldAffordances.js +424 -213
  12. package/dist/shared/components/item-edit/FieldRow.js +475 -427
  13. package/dist/shared/components/item-edit/PersonalDefaultControl.js +211 -0
  14. package/dist/shared/components/item-edit/PersonalDefaultPill.js +20 -0
  15. package/dist/shared/components/item-edit/RecordLiveSync.js +115 -110
  16. package/dist/shared/components/item-edit/RelationCombobox.js +42 -41
  17. package/dist/shared/components/item-edit/catalog-search.js +34 -0
  18. package/dist/shared/components/item-edit/entry/useEntryKeyboard.js +43 -43
  19. package/dist/shared/components/item-edit/live-record-marks.js +13 -0
  20. package/dist/shared/components/item-edit/personal-default-checks.js +134 -0
  21. package/dist/shared/components/item-edit/usePersonalDefaults.js +442 -0
  22. package/dist/shared/components/layout-editor/inspector/BehaviourSettings.js +130 -111
  23. package/dist/shared/components/layout-editor/inspector/RulesTab.js +76 -75
  24. package/dist/shared/components/layout-editor/parity-keys.json.js +1 -1
  25. package/dist/shared/components/profile/MyDefaultsCard.js +667 -0
  26. package/dist/shared/components/profile/PersonProfile.js +42 -40
  27. package/dist/shared/components/profile/my-defaults-labels.js +76 -0
  28. package/dist/shared/components/profile/primitives.js +72 -67
  29. package/dist/shared/lib/personal-defaults.js +76 -0
  30. package/dist/shared/lib/request-gate.js +78 -76
  31. package/dist/shared/lib/search-text.js +111 -0
  32. package/package.json +1 -1
@@ -1,27 +1,31 @@
1
- import { jsxs as c, jsx as n } from "react/jsx-runtime";
2
- import { useQueryClient as Pe, useQueries as at, useQuery as ne, useMutation as it } from "@tanstack/react-query";
3
- import { Info as ot, Loader2 as st, Sparkles as dt, Lock as ct, SlidersHorizontal as ut, History as mt, BellRing as pt, Bell as ht, Sigma as xt } from "lucide-react";
4
- import { memo as ft, useState as fe, useRef as L, useId as yt, useEffect as re, useCallback as Ee } from "react";
5
- import { toast as K } from "sonner";
6
- import { useParentDraft as bt, useNivaroClient as le } from "../../context.js";
7
- import { showsAiButton as gt, AUTOFILL_CHECK_KEY as vt, readAiFill as wt } from "../../lib/ai-fill.js";
8
- import { get as U, del as kt, post as xe } from "../../lib/commands.js";
9
- import { titleCase as he, cn as P } from "../../lib/utils.js";
10
- import { GlossaryLabel as je } from "../ai/GlossaryText.js";
11
- import { Label as _t } from "../ui/label.js";
12
- import { TooltipProvider as Z, Tooltip as I, TooltipTrigger as ee, TooltipContent as te } from "../ui/tooltip.js";
13
- import { useAddendumFields as Nt } from "./AddendumFieldContext.js";
14
- import { AutoIdPreviewField as Ft } from "./AutoIdPreviewField.js";
15
- import { useFieldAffordances as Ct, useFieldContextMenu as Lt, usePresenceSoftLock as Rt, LockReasonBadge as $t, PresenceSoftLockStrip as St, RemoteChangeGhost as Tt } from "./FieldAffordances.js";
16
- import { FieldRenderer as qt } from "./FieldRenderer.js";
17
- import { FormHelpVideoButton as At } from "./FormHelpVideoButton.js";
18
- import { getCascadeFilters as Et, SYSTEM_FIELDS as jt, parseJson as Pt, buildCascadeFilter as Dt, CascadeEffectController as Mt } from "./helpers.js";
19
- import { isDerivedForRecord as Ot } from "./live-rollups.js";
20
- import { useM2MStaging as Bt } from "./M2MStagingContext.js";
21
- import { usePlacementTextContext as Kt, placementFieldText as Ut, isDisplayFormulaRow as Ht, fieldCounterConfig as Wt, fieldIsRecommended as Vt, RecommendedMarker as zt, RepeatLastButton as Gt, DisplayFormulaValue as Qt, FieldCounter as Yt } from "./placement-behaviour.js";
22
- import { keepIfEqual as Jt, jsonEqual as Xt } from "./render-stability.js";
23
- import { resolveOptionFilterTokens as Zt } from "../../lib/option-filter-tokens.js";
24
- const It = /* @__PURE__ */ new Set(["integer", "float", "decimal", "bigInteger", "number"]), en = /* @__PURE__ */ new Set(["string", "text", "richtext", "textarea", "markdown", "json", "csv"]), tn = /* @__PURE__ */ new Set([
1
+ import { jsxs as c, jsx as r } from "react/jsx-runtime";
2
+ import { useQueryClient as We, useQueries as xt, useQuery as le, useMutation as ft } from "@tanstack/react-query";
3
+ import { Info as yt, Loader2 as bt, Sparkles as gt, Lock as vt, SlidersHorizontal as wt, History as kt, BellRing as _t, Bell as Nt, Sigma as Ft } from "lucide-react";
4
+ import { memo as Ct, useState as we, useRef as R, useId as Lt, useEffect as ae, useCallback as Me } from "react";
5
+ import { toast as U } from "sonner";
6
+ import { useParentDraft as Rt, useNivaroClient as oe } from "../../context.js";
7
+ import { showsAiButton as St, AUTOFILL_CHECK_KEY as $t, readAiFill as qt } from "../../lib/ai-fill.js";
8
+ import { get as H, del as Tt, post as ve } from "../../lib/commands.js";
9
+ import { titleCase as ge, cn as D } from "../../lib/utils.js";
10
+ import { GlossaryLabel as Ke } from "../ai/GlossaryText.js";
11
+ import { Label as At } from "../ui/label.js";
12
+ import { TooltipProvider as ee, Tooltip as te, TooltipTrigger as ne, TooltipContent as re } from "../ui/tooltip.js";
13
+ import { useAddendumFields as Et } from "./AddendumFieldContext.js";
14
+ import { AutoIdPreviewField as Pt } from "./AutoIdPreviewField.js";
15
+ import { FOCUSABLE as Ue } from "./entry/entry-keys.js";
16
+ import { useFieldAffordances as jt, useFieldContextMenu as Dt, usePresenceSoftLock as Ot, LockReasonBadge as Bt, PresenceSoftLockStrip as Mt, RemoteChangeGhost as Kt } from "./FieldAffordances.js";
17
+ import { FieldRenderer as Ut } from "./FieldRenderer.js";
18
+ import { FormHelpVideoButton as Ht } from "./FormHelpVideoButton.js";
19
+ import { getCascadeFilters as Wt, SYSTEM_FIELDS as Vt, parseJson as zt, buildCascadeFilter as Gt, CascadeEffectController as Qt } from "./helpers.js";
20
+ import { isDerivedForRecord as Yt } from "./live-rollups.js";
21
+ import { useM2MStaging as Jt } from "./M2MStagingContext.js";
22
+ import { personalDefaultSlotFor as Xt, PersonalDefaultSlot as Zt } from "./PersonalDefaultControl.js";
23
+ import { PersonalDefaultHint as It } from "./PersonalDefaultPill.js";
24
+ import { isDisplayFormulaRow as He, usePlacementTextContext as en, placementFieldText as tn, fieldCounterConfig as nn, fieldIsRecommended as rn, RecommendedMarker as ln, RepeatLastButton as an, DisplayFormulaValue as on, FieldCounter as sn } from "./placement-behaviour.js";
25
+ import { keepIfEqual as dn, jsonEqual as cn } from "./render-stability.js";
26
+ import { usePersonalDefaultsApi as un } from "./usePersonalDefaults.js";
27
+ import { resolveOptionFilterTokens as mn } from "../../lib/option-filter-tokens.js";
28
+ const pn = /* @__PURE__ */ new Set(["integer", "float", "decimal", "bigInteger", "number"]), hn = /* @__PURE__ */ new Set(["string", "text", "richtext", "textarea", "markdown", "json", "csv"]), xn = /* @__PURE__ */ new Set([
25
29
  "input",
26
30
  "textarea",
27
31
  "wysiwyg",
@@ -29,7 +33,7 @@ const It = /* @__PURE__ */ new Set(["integer", "float", "decimal", "bigInteger",
29
33
  "input-rich-text-html",
30
34
  "rich_text",
31
35
  "extension-editorjs"
32
- ]), nn = /* @__PURE__ */ new Set([
36
+ ]), fn = /* @__PURE__ */ new Set([
33
37
  "relation-m2o",
34
38
  "relation-m2m",
35
39
  "select-multiple-m2m",
@@ -40,108 +44,108 @@ const It = /* @__PURE__ */ new Set(["integer", "float", "decimal", "bigInteger",
40
44
  "file",
41
45
  "files",
42
46
  "image"
43
- ]), rn = /* @__PURE__ */ new Set(["file", "file-image", "files-m2m", "files", "image"]);
44
- function ln(d) {
47
+ ]), yn = /* @__PURE__ */ new Set(["file", "file-image", "files-m2m", "files", "image"]);
48
+ function bn(d) {
45
49
  const e = d.interface ?? "";
46
- return nn.has(e) || e.startsWith("relation-") || e.endsWith("-m2o") || e.endsWith("-m2m") ? !1 : !!(en.has(d.type ?? "") || tn.has(e) || !e && d.type && !It.has(d.type));
50
+ return fn.has(e) || e.startsWith("relation-") || e.endsWith("-m2o") || e.endsWith("-m2m") ? !1 : !!(hn.has(d.type ?? "") || xn.has(e) || !e && d.type && !pn.has(d.type));
47
51
  }
48
- function an(d, e, u, p) {
49
- const f = le();
50
- return ne({
51
- queryKey: ["field-lineage", d, e, u],
52
+ function gn(d, e, m, p) {
53
+ const f = oe();
54
+ return le({
55
+ queryKey: ["field-lineage", d, e, m],
52
56
  queryFn: () => f.request(
53
- U(`/lineage/${d}/${encodeURIComponent(e)}/${u}`)
54
- ).then((o) => o.data),
57
+ H(`/lineage/${d}/${encodeURIComponent(e)}/${m}`)
58
+ ).then((i) => i.data),
55
59
  enabled: p,
56
60
  staleTime: 3e4
57
61
  });
58
62
  }
59
- function En(d, e = "rows") {
63
+ function Xn(d, e = "rows") {
60
64
  var l, N, b;
61
65
  if (d && (d.kind === "write" || d.kind === "read") && d.formula) {
62
- const m = (y) => typeof y == "number" ? y.toLocaleString(void 0, { maximumFractionDigits: 2 }) : y == null || y === "" ? "∅" : String(y);
66
+ const u = (y) => typeof y == "number" ? y.toLocaleString(void 0, { maximumFractionDigits: 2 }) : y == null || y === "" ? "∅" : String(y);
63
67
  return `= ${d.formula.replace(/item\.([A-Za-z_][A-Za-z0-9_]*)/g, (y, a) => {
64
68
  var x;
65
- return m((x = d.inputs) == null ? void 0 : x[a]);
69
+ return u((x = d.inputs) == null ? void 0 : x[a]);
66
70
  }).replace(/\s*-\s*/g, " − ").replace(/\s*\*\s*/g, " × ").replace(/\s*\/\s*/g, " ÷ ")}`;
67
71
  }
68
72
  if (!d || d.kind !== "rollup") return null;
69
- const u = (d.sources ?? []).reduce((m, i) => m + i.rows.length, 0), p = (d.sources ?? []).reduce((m, i) => {
73
+ const m = (d.sources ?? []).reduce((u, o) => u + o.rows.length, 0), p = (d.sources ?? []).reduce((u, o) => {
70
74
  var y;
71
- return m + (((y = i.excluded) == null ? void 0 : y.length) ?? 0);
72
- }, 0), f = (b = (N = (l = (d.sources ?? []).find((m) => {
73
- var i;
74
- return (i = m.excluded) == null ? void 0 : i.length;
75
- })) == null ? void 0 : l.excluded) == null ? void 0 : N[0]) == null ? void 0 : b.reason, o = [`= ${u} ${u === 1 ? e.replace(/s$/, "") : e}`];
76
- return p && o.push(
75
+ return u + (((y = o.excluded) == null ? void 0 : y.length) ?? 0);
76
+ }, 0), f = (b = (N = (l = (d.sources ?? []).find((u) => {
77
+ var o;
78
+ return (o = u.excluded) == null ? void 0 : o.length;
79
+ })) == null ? void 0 : l.excluded) == null ? void 0 : N[0]) == null ? void 0 : b.reason, i = [`= ${m} ${m === 1 ? e.replace(/s$/, "") : e}`];
80
+ return p && i.push(
77
81
  `${p} excluded${f ? ` (${f.replace(/^does not match: /, "")})` : ""}`
78
- ), o.join(" · ");
82
+ ), i.join(" · ");
79
83
  }
80
- function on({
84
+ function vn({
81
85
  collection: d,
82
86
  itemId: e,
83
- field: u
87
+ field: m
84
88
  }) {
85
- const [p, f] = fe(!1), o = L(null), { data: l, isLoading: N } = an(d, e, u, p);
86
- re(() => {
89
+ const [p, f] = we(!1), i = R(null), { data: l, isLoading: N } = gn(d, e, m, p);
90
+ ae(() => {
87
91
  if (!p) return;
88
- const i = (y) => {
92
+ const o = (y) => {
89
93
  var a;
90
- (a = o.current) != null && a.contains(y.target) || f(!1);
94
+ (a = i.current) != null && a.contains(y.target) || f(!1);
91
95
  };
92
- return window.addEventListener("mousedown", i), () => window.removeEventListener("mousedown", i);
96
+ return window.addEventListener("mousedown", o), () => window.removeEventListener("mousedown", o);
93
97
  }, [p]);
94
- const b = (i) => i == null ? "—" : Number(i).toLocaleString(void 0, { maximumFractionDigits: 2 }), m = (l == null ? void 0 : l.stored_value) != null ? Number(l.stored_value) : null;
95
- return /* @__PURE__ */ c("div", { ref: o, className: "relative inline-flex", children: [
96
- /* @__PURE__ */ n(
98
+ const b = (o) => o == null ? "—" : Number(o).toLocaleString(void 0, { maximumFractionDigits: 2 }), u = (l == null ? void 0 : l.stored_value) != null ? Number(l.stored_value) : null;
99
+ return /* @__PURE__ */ c("div", { ref: i, className: "relative inline-flex", children: [
100
+ /* @__PURE__ */ r(
97
101
  "button",
98
102
  {
99
103
  type: "button",
100
- onClick: () => f((i) => !i),
104
+ onClick: () => f((o) => !o),
101
105
  title: "Where does this number come from?",
102
- className: P(
106
+ className: D(
103
107
  "inline-flex items-center rounded p-0.5 transition-opacity",
104
108
  p ? "text-nvr-cyan opacity-100" : "text-slate-400 hover:text-nvr-cyan dark:text-slate-300 dark:hover:text-nvr-cyan"
105
109
  ),
106
110
  "data-field-lineage": !0,
107
- children: /* @__PURE__ */ n(xt, { className: "h-3 w-3" })
111
+ children: /* @__PURE__ */ r(Ft, { className: "h-3 w-3" })
108
112
  }
109
113
  ),
110
114
  p && /* @__PURE__ */ c("div", { className: "absolute left-0 top-full z-40 mt-1 max-h-[340px] w-[360px] overflow-y-auto rounded-lg border border-slate-200 bg-white p-2 shadow-lg dark:border-border dark:bg-card", children: [
111
- /* @__PURE__ */ n("p", { className: "mb-1 px-1 text-[10px] font-semibold uppercase tracking-wide text-slate-400", children: "Where this number comes from" }),
112
- N && /* @__PURE__ */ n("p", { className: "px-1 py-2 text-[11.5px] text-slate-400", children: "Loading…" }),
115
+ /* @__PURE__ */ r("p", { className: "mb-1 px-1 text-[10px] font-semibold uppercase tracking-wide text-slate-400", children: "Where this number comes from" }),
116
+ N && /* @__PURE__ */ r("p", { className: "px-1 py-2 text-[11.5px] text-slate-400", children: "Loading…" }),
113
117
  (l == null ? void 0 : l.kind) === "write" && /* @__PURE__ */ c("div", { className: "space-y-1 px-1 py-1", children: [
114
- /* @__PURE__ */ n("p", { className: "font-mono text-[11px] text-slate-600 dark:text-slate-300", children: l.formula }),
115
- Object.entries(l.inputs ?? {}).map(([i, y]) => /* @__PURE__ */ c("p", { className: "text-[11.5px] text-slate-500 dark:text-muted-foreground", children: [
116
- /* @__PURE__ */ n("span", { className: "font-mono", children: i }),
118
+ /* @__PURE__ */ r("p", { className: "font-mono text-[11px] text-slate-600 dark:text-slate-300", children: l.formula }),
119
+ Object.entries(l.inputs ?? {}).map(([o, y]) => /* @__PURE__ */ c("p", { className: "text-[11.5px] text-slate-500 dark:text-muted-foreground", children: [
120
+ /* @__PURE__ */ r("span", { className: "font-mono", children: o }),
117
121
  " = ",
118
122
  b(y)
119
- ] }, i)),
123
+ ] }, o)),
120
124
  /* @__PURE__ */ c("p", { className: "pt-1 text-[11.5px] font-medium text-slate-700 dark:text-slate-200", children: [
121
125
  "= ",
122
126
  b(l.stored_value)
123
127
  ] })
124
128
  ] }),
125
- (l == null ? void 0 : l.kind) === "rollup" && (l.sources ?? []).map((i, y) => {
129
+ (l == null ? void 0 : l.kind) === "rollup" && (l.sources ?? []).map((o, y) => {
126
130
  var a;
127
131
  return /* @__PURE__ */ c("div", { className: "mb-1.5", children: [
128
132
  /* @__PURE__ */ c("p", { className: "px-1 text-[10.5px] text-slate-400", children: [
129
- (i.aggregate ?? "sum").toUpperCase(),
130
- i.value_field ? ` of ${i.value_field}` : "",
133
+ (o.aggregate ?? "sum").toUpperCase(),
134
+ o.value_field ? ` of ${o.value_field}` : "",
131
135
  " across ",
132
- i.collection,
133
- i.filtered ? " (filtered)" : ""
136
+ o.collection,
137
+ o.filtered ? " (filtered)" : ""
134
138
  ] }),
135
- i.error && /* @__PURE__ */ n("p", { className: "px-1 py-1 text-[11.5px] text-amber-600 dark:text-amber-400", children: i.error }),
136
- i.note && /* @__PURE__ */ n("p", { className: "px-1 py-1 text-[11.5px] text-slate-400", children: i.note }),
137
- i.rows.length > 0 && /* @__PURE__ */ n("div", { className: "mt-0.5 space-y-px", children: i.rows.map((x) => /* @__PURE__ */ c(
139
+ o.error && /* @__PURE__ */ r("p", { className: "px-1 py-1 text-[11.5px] text-amber-600 dark:text-amber-400", children: o.error }),
140
+ o.note && /* @__PURE__ */ r("p", { className: "px-1 py-1 text-[11.5px] text-slate-400", children: o.note }),
141
+ o.rows.length > 0 && /* @__PURE__ */ r("div", { className: "mt-0.5 space-y-px", children: o.rows.map((x) => /* @__PURE__ */ c(
138
142
  "div",
139
143
  {
140
144
  className: "flex items-baseline gap-2 rounded px-1 py-0.5 text-[11.5px] hover:bg-slate-50 dark:hover:bg-muted",
141
145
  children: [
142
- /* @__PURE__ */ n("span", { className: "min-w-0 flex-1 truncate text-slate-600 dark:text-slate-300", children: x.label }),
143
- /* @__PURE__ */ n("span", { className: "shrink-0 font-mono tabular-nums text-slate-800 dark:text-slate-100", children: b(x.value) }),
144
- /* @__PURE__ */ n(
146
+ /* @__PURE__ */ r("span", { className: "min-w-0 flex-1 truncate text-slate-600 dark:text-slate-300", children: x.label }),
147
+ /* @__PURE__ */ r("span", { className: "shrink-0 font-mono tabular-nums text-slate-800 dark:text-slate-100", children: b(x.value) }),
148
+ /* @__PURE__ */ r(
145
149
  "span",
146
150
  {
147
151
  className: "w-[88px] shrink-0 truncate text-right text-[10px] text-slate-400",
@@ -153,95 +157,95 @@ function on({
153
157
  },
154
158
  x.id
155
159
  )) }),
156
- i.truncated && /* @__PURE__ */ n("p", { className: "px-1 pt-0.5 text-[10.5px] text-amber-600 dark:text-amber-400", children: "Showing the first 200 rows — the subtotal covers only these." }),
157
- i.subtotal != null && /* @__PURE__ */ c("p", { className: "border-t border-slate-100 px-1 pt-1 text-right text-[11.5px] font-medium text-slate-700 dark:border-border dark:text-slate-200", children: [
160
+ o.truncated && /* @__PURE__ */ r("p", { className: "px-1 pt-0.5 text-[10.5px] text-amber-600 dark:text-amber-400", children: "Showing the first 200 rows — the subtotal covers only these." }),
161
+ o.subtotal != null && /* @__PURE__ */ c("p", { className: "border-t border-slate-100 px-1 pt-1 text-right text-[11.5px] font-medium text-slate-700 dark:border-border dark:text-slate-200", children: [
158
162
  "subtotal ",
159
- b(i.subtotal)
163
+ b(o.subtotal)
160
164
  ] }),
161
- (((a = i.excluded) == null ? void 0 : a.length) ?? 0) > 0 && /* @__PURE__ */ c("div", { className: "mt-1 rounded bg-slate-50 px-1 py-1 dark:bg-muted/40", children: [
165
+ (((a = o.excluded) == null ? void 0 : a.length) ?? 0) > 0 && /* @__PURE__ */ c("div", { className: "mt-1 rounded bg-slate-50 px-1 py-1 dark:bg-muted/40", children: [
162
166
  /* @__PURE__ */ c("p", { className: "text-[10.5px] text-slate-500 dark:text-muted-foreground", children: [
163
- i.excluded.length,
167
+ o.excluded.length,
164
168
  " excluded —",
165
169
  " ",
166
- i.excluded[0].reason.replace(/^does not match: /, "")
170
+ o.excluded[0].reason.replace(/^does not match: /, "")
167
171
  ] }),
168
- i.excluded.slice(0, 8).map((x) => /* @__PURE__ */ c(
172
+ o.excluded.slice(0, 8).map((x) => /* @__PURE__ */ c(
169
173
  "div",
170
174
  {
171
175
  className: "flex items-baseline gap-2 px-0.5 text-[11px] text-slate-400",
172
176
  children: [
173
- /* @__PURE__ */ n("span", { className: "min-w-0 flex-1 truncate line-through decoration-slate-300", children: x.label }),
174
- /* @__PURE__ */ n("span", { className: "shrink-0 font-mono tabular-nums", children: b(x.value) })
177
+ /* @__PURE__ */ r("span", { className: "min-w-0 flex-1 truncate line-through decoration-slate-300", children: x.label }),
178
+ /* @__PURE__ */ r("span", { className: "shrink-0 font-mono tabular-nums", children: b(x.value) })
175
179
  ]
176
180
  },
177
181
  x.id
178
182
  )),
179
- i.excluded.length > 8 && /* @__PURE__ */ c("p", { className: "px-0.5 text-[10.5px] text-slate-400", children: [
183
+ o.excluded.length > 8 && /* @__PURE__ */ c("p", { className: "px-0.5 text-[10.5px] text-slate-400", children: [
180
184
  "+",
181
- i.excluded.length - 8,
185
+ o.excluded.length - 8,
182
186
  " more"
183
187
  ] })
184
188
  ] })
185
189
  ] }, y);
186
190
  }),
187
- (l == null ? void 0 : l.kind) === "rollup" && m != null && /* @__PURE__ */ c("p", { className: "px-1 pt-0.5 text-right text-[11.5px] text-slate-500 dark:text-muted-foreground", children: [
191
+ (l == null ? void 0 : l.kind) === "rollup" && u != null && /* @__PURE__ */ c("p", { className: "px-1 pt-0.5 text-right text-[11.5px] text-slate-500 dark:text-muted-foreground", children: [
188
192
  "stored ",
189
- b(m),
193
+ b(u),
190
194
  (() => {
191
- const i = (l.sources ?? []).reduce((a, x) => a + (x.subtotal ?? 0), 0);
192
- return (l.sources ?? []).some((a) => a.truncated) ? null : Math.abs(i - m) < 0.01 ? /* @__PURE__ */ n("span", { className: "ml-1 text-emerald-600 dark:text-emerald-400", children: "✓ matches" }) : /* @__PURE__ */ n("span", { className: "ml-1 text-amber-600 dark:text-amber-400", children: "✕ differs from contributions" });
195
+ const o = (l.sources ?? []).reduce((a, x) => a + (x.subtotal ?? 0), 0);
196
+ return (l.sources ?? []).some((a) => a.truncated) ? null : Math.abs(o - u) < 0.01 ? /* @__PURE__ */ r("span", { className: "ml-1 text-emerald-600 dark:text-emerald-400", children: "✓ matches" }) : /* @__PURE__ */ r("span", { className: "ml-1 text-amber-600 dark:text-amber-400", children: "✕ differs from contributions" });
193
197
  })()
194
198
  ] })
195
199
  ] })
196
200
  ] });
197
201
  }
198
- function sn({
202
+ function wn({
199
203
  collection: d,
200
204
  itemId: e,
201
- field: u,
205
+ field: m,
202
206
  formatValue: p,
203
207
  onRestore: f
204
208
  }) {
205
- const o = le(), [l, N] = fe(!1), b = L(null), { data: m, isLoading: i } = ne({
206
- queryKey: ["field-value-history", d, e, u],
207
- queryFn: () => o.request(U(`/field-history/${d}/${encodeURIComponent(e)}/${u}`)).then((a) => a.data ?? []),
209
+ const i = oe(), [l, N] = we(!1), b = R(null), { data: u, isLoading: o } = le({
210
+ queryKey: ["field-value-history", d, e, m],
211
+ queryFn: () => i.request(H(`/field-history/${d}/${encodeURIComponent(e)}/${m}`)).then((a) => a.data ?? []),
208
212
  enabled: l,
209
213
  staleTime: 6e4
210
214
  });
211
- re(() => {
215
+ ae(() => {
212
216
  if (!l) return;
213
217
  const a = (x) => {
214
- var H;
215
- (H = b.current) != null && H.contains(x.target) || N(!1);
218
+ var W;
219
+ (W = b.current) != null && W.contains(x.target) || N(!1);
216
220
  };
217
221
  return window.addEventListener("mousedown", a), () => window.removeEventListener("mousedown", a);
218
222
  }, [l]);
219
223
  const y = (a, x) => x || (a == null || a === "" ? "—" : p ? p(a) : typeof a == "boolean" || a === "true" || a === "false" ? a === !0 || a === "true" ? "Yes" : "No" : typeof a == "string" && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/.test(a) ? new Date(a).toLocaleString() : typeof a == "object" ? JSON.stringify(a).slice(0, 60) : String(a).slice(0, 80));
220
224
  return /* @__PURE__ */ c("div", { ref: b, className: "relative inline-flex", children: [
221
- /* @__PURE__ */ n(
225
+ /* @__PURE__ */ r(
222
226
  "button",
223
227
  {
224
228
  type: "button",
225
229
  onClick: () => N((a) => !a),
226
230
  title: "Value history",
227
- className: P(
231
+ className: D(
228
232
  "inline-flex items-center rounded p-0.5 transition-opacity",
229
233
  l ? "text-nvr-cyan opacity-100" : "text-slate-400 hover:text-nvr-cyan dark:text-slate-300 dark:hover:text-nvr-cyan"
230
234
  ),
231
235
  "data-field-history": !0,
232
- children: /* @__PURE__ */ n(mt, { className: "h-3 w-3" })
236
+ children: /* @__PURE__ */ r(kt, { className: "h-3 w-3" })
233
237
  }
234
238
  ),
235
239
  l && /* @__PURE__ */ c("div", { className: "absolute left-0 top-full z-40 mt-1 max-h-64 w-[300px] overflow-y-auto rounded-lg border border-slate-200 bg-white p-2 shadow-lg dark:border-border dark:bg-card", children: [
236
- /* @__PURE__ */ n("p", { className: "mb-1 px-1 text-[10px] font-semibold uppercase tracking-wide text-slate-400", children: "Value history" }),
237
- i ? /* @__PURE__ */ n("p", { className: "px-1 py-2 text-[11.5px] text-slate-400", children: "Loading…" }) : (m ?? []).length === 0 ? /* @__PURE__ */ n("p", { className: "px-1 py-2 text-[11.5px] text-slate-400", children: "No recorded changes for this field." }) : /* @__PURE__ */ n("div", { className: "space-y-1", children: (m ?? []).map((a, x) => /* @__PURE__ */ c(
240
+ /* @__PURE__ */ r("p", { className: "mb-1 px-1 text-[10px] font-semibold uppercase tracking-wide text-slate-400", children: "Value history" }),
241
+ o ? /* @__PURE__ */ r("p", { className: "px-1 py-2 text-[11.5px] text-slate-400", children: "Loading…" }) : (u ?? []).length === 0 ? /* @__PURE__ */ r("p", { className: "px-1 py-2 text-[11.5px] text-slate-400", children: "No recorded changes for this field." }) : /* @__PURE__ */ r("div", { className: "space-y-1", children: (u ?? []).map((a, x) => /* @__PURE__ */ c(
238
242
  "div",
239
243
  {
240
244
  className: "rounded px-1 py-1 text-[11.5px] leading-snug hover:bg-slate-50 dark:hover:bg-muted",
241
245
  children: [
242
246
  /* @__PURE__ */ c("span", { className: "flex items-baseline justify-between gap-2", children: [
243
- /* @__PURE__ */ n("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: y(a.value, a.display) }),
244
- f && x > 0 && /* @__PURE__ */ n(
247
+ /* @__PURE__ */ r("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: y(a.value, a.display) }),
248
+ f && x > 0 && /* @__PURE__ */ r(
245
249
  "button",
246
250
  {
247
251
  type: "button",
@@ -257,7 +261,7 @@ function sn({
257
261
  a.action === "create" ? "initial value" : "changed",
258
262
  a.timestamp ? ` · ${new Date(a.timestamp).toLocaleString()}` : "",
259
263
  a.user_name ? ` · ${a.user_name}` : "",
260
- a.origin && a.origin.kind !== "user" && /* @__PURE__ */ n(
264
+ a.origin && a.origin.kind !== "user" && /* @__PURE__ */ r(
261
265
  "span",
262
266
  {
263
267
  className: a.origin.kind === "integration" ? "ml-1 rounded bg-purple-500/10 px-1 py-px text-[9.5px] font-medium text-purple-700 dark:text-purple-400" : a.origin.kind === "import" ? "ml-1 rounded bg-sky-500/10 px-1 py-px text-[9.5px] font-medium text-sky-700 dark:text-sky-400" : "ml-1 rounded bg-amber-500/10 px-1 py-px text-[9.5px] font-medium text-amber-700 dark:text-amber-400",
@@ -277,274 +281,280 @@ function sn({
277
281
  ] })
278
282
  ] });
279
283
  }
280
- function dn({
284
+ function kn({
281
285
  collection: d,
282
286
  itemId: e,
283
- field: u
287
+ field: m
284
288
  }) {
285
- const p = le(), f = Pe(), { data: o } = ne({
289
+ const p = oe(), f = We(), { data: i } = le({
286
290
  queryKey: ["field-watch-config"],
287
- queryFn: () => p.request(U("/field-watches/config")).then((i) => i.data).catch(() => ({ enabled: !1 })),
291
+ queryFn: () => p.request(H("/field-watches/config")).then((o) => o.data).catch(() => ({ enabled: !1 })),
288
292
  staleTime: 5 * 6e4
289
- }), l = ["field-watch-self", d, e], { data: N = [] } = ne({
293
+ }), l = ["field-watch-self", d, e], { data: N = [] } = le({
290
294
  queryKey: l,
291
- queryFn: () => p.request(U("/field-watches/self", { collection: d, item_id: e })).then((i) => i.data ?? []).catch(() => []),
292
- enabled: !!(o != null && o.enabled),
295
+ queryFn: () => p.request(H("/field-watches/self", { collection: d, item_id: e })).then((o) => o.data ?? []).catch(() => []),
296
+ enabled: !!(i != null && i.enabled),
293
297
  staleTime: 6e4
294
- }), b = N.includes(u), m = it({
298
+ }), b = N.includes(m), u = ft({
295
299
  mutationFn: () => b ? p.request(
296
- kt(
297
- `/field-watches/self?collection=${encodeURIComponent(d)}&field=${encodeURIComponent(u)}&item_id=${encodeURIComponent(e)}`
300
+ Tt(
301
+ `/field-watches/self?collection=${encodeURIComponent(d)}&field=${encodeURIComponent(m)}&item_id=${encodeURIComponent(e)}`
298
302
  )
299
- ) : p.request(xe("/field-watches/self", { collection: d, field: u, item_id: e })),
303
+ ) : p.request(ve("/field-watches/self", { collection: d, field: m, item_id: e })),
300
304
  onSuccess: () => {
301
- f.invalidateQueries({ queryKey: l }), K.success(
305
+ f.invalidateQueries({ queryKey: l }), U.success(
302
306
  b ? "No longer watching this field" : "Watching — you will be notified when it changes"
303
307
  );
304
308
  },
305
- onError: () => K.error("Could not update the watch")
309
+ onError: () => U.error("Could not update the watch")
306
310
  });
307
- return o != null && o.enabled ? /* @__PURE__ */ n(
311
+ return i != null && i.enabled ? /* @__PURE__ */ r(
308
312
  "button",
309
313
  {
310
314
  type: "button",
311
- onClick: () => m.mutate(),
315
+ onClick: () => u.mutate(),
312
316
  title: b ? "Stop watching this field on this record" : "Watch this field on this record",
313
- "data-field-watch": u,
317
+ "data-field-watch": m,
314
318
  className: `rounded p-0.5 transition-colors ${b ? "text-nvr-navy dark:text-nvr-cyan" : "text-slate-300 hover:text-slate-500"}`,
315
- children: b ? /* @__PURE__ */ n(pt, { className: "h-3 w-3" }) : /* @__PURE__ */ n(ht, { className: "h-3 w-3" })
319
+ children: b ? /* @__PURE__ */ r(_t, { className: "h-3 w-3" }) : /* @__PURE__ */ r(Nt, { className: "h-3 w-3" })
316
320
  }
317
321
  ) : null;
318
322
  }
319
- function cn(d) {
323
+ function _n(d) {
320
324
  return d ? d.querySelector(
321
325
  'input:not([type=hidden]), textarea, [role="combobox"], [contenteditable="true"]'
322
326
  ) ?? d.querySelector("button") : null;
323
327
  }
324
- const jn = ft(function({
328
+ const Zn = Ct(function({
325
329
  field: e,
326
- draft: u,
330
+ draft: m,
327
331
  onChange: p,
328
332
  relations: f,
329
- collection: o,
333
+ collection: i,
330
334
  itemId: l,
331
335
  error: N,
332
336
  visible: b,
333
- locked: m,
334
- layoutAiEnabled: i,
337
+ locked: u,
338
+ layoutAiEnabled: o,
335
339
  renderField: y,
336
340
  onCountChange: a,
337
341
  swapButton: x,
338
- swapContent: H,
339
- forceVisible: De,
340
- autoFillTick: ae
342
+ swapContent: W,
343
+ forceVisible: Ve,
344
+ autoFillTick: ie
341
345
  }) {
342
- var Te, qe, Ae;
343
- const W = rn.has(e.interface ?? ""), C = bt(), g = Bt(), ye = Pe(), ie = le(), [be, V] = fe(!1), s = Ct(), oe = L(null), z = yt(), ge = L(null), ve = L(!1);
344
- re(() => {
345
- const t = ve.current ? cn(ge.current) : null;
346
+ var De, Oe, Be;
347
+ const V = yn.has(e.interface ?? ""), C = Rt(), g = Jt(), ke = We(), se = oe(), [_e, z] = we(!1), s = jt(), G = R(null), Q = Lt(), de = R(null), Ne = R(!1);
348
+ ae(() => {
349
+ const t = Ne.current ? _n(de.current) : null;
346
350
  if (!t || t.hasAttribute("aria-label")) return;
347
- t.id || (t.id = `${z}-control`);
348
- const r = t.tagName === "BUTTON" ? `${z} ${t.id}` : z;
349
- t.getAttribute("aria-labelledby") !== r && t.setAttribute("aria-labelledby", r);
351
+ t.id || (t.id = `${Q}-control`);
352
+ const n = t.tagName === "BUTTON" ? `${Q} ${t.id}` : Q;
353
+ t.getAttribute("aria-labelledby") !== n && t.setAttribute("aria-labelledby", n);
350
354
  });
351
- const we = m && !W, ke = L(null);
352
- re(() => {
353
- const t = ke.current;
355
+ const Fe = u && !V, Ce = R(null);
356
+ ae(() => {
357
+ const t = Ce.current;
354
358
  if (!t) return;
355
- if (!we) {
359
+ if (!Fe) {
356
360
  t.removeAttribute("inert");
357
361
  return;
358
362
  }
359
- const r = typeof document < "u" ? document.activeElement : null;
360
- r instanceof HTMLElement && t.contains(r) && r.blur(), t.setAttribute("inert", "");
361
- }, [we, ae]);
362
- const G = e.field, _e = Ee(
363
+ const n = typeof document < "u" ? document.activeElement : null;
364
+ n instanceof HTMLElement && t.contains(n) && n.blur(), t.setAttribute("inert", "");
365
+ }, [Fe, ie]);
366
+ const Y = e.field, Le = Me(
363
367
  (t) => {
364
- m || p(G, t);
368
+ u || p(Y, t);
365
369
  },
366
- [m, p, G]
367
- ), Me = Ee(
368
- (t) => a == null ? void 0 : a(G, t),
369
- [a, G]
370
- ), Oe = L(void 0), Ne = L(void 0), Fe = L(void 0), {
371
- onContextMenu: Be,
372
- onKeyDown: Ke,
373
- menu: Ue
374
- } = Lt({
375
- wrapperRef: oe,
370
+ [u, p, Y]
371
+ ), ze = Me(
372
+ (t) => a == null ? void 0 : a(Y, t),
373
+ [a, Y]
374
+ ), Ge = R(void 0), Re = R(void 0), Se = R(void 0), $e = !u && !e.readonly && !e.computed_formula && !(e.hidden && !e.layout_assigned) && !He(e), {
375
+ onContextMenu: Qe,
376
+ onKeyDown: Ye,
377
+ menu: Je,
378
+ confirmSaveFrom: Xe,
379
+ openedBy: ce
380
+ } = Dt({
381
+ wrapperRef: G,
376
382
  field: e,
377
- value: u[e.field],
383
+ value: m[e.field],
378
384
  relations: f,
379
- collection: o,
385
+ collection: i,
380
386
  itemId: l,
381
- openRelated: s == null ? void 0 : s.openRelated
382
- }), q = Rt(oe), He = Kt(), Ce = s == null ? void 0 : s.remoteChanges[e.field], D = s == null ? void 0 : s.lockReasons[e.field], $ = s == null ? void 0 : s.applyToLines[e.field], Q = gt(e._overrides, i, ln(e)), se = !!(s != null && s.fromAutofill) && !!e._overrides && e._overrides[vt] === !0;
383
- async function We() {
387
+ openRelated: s == null ? void 0 : s.openRelated,
388
+ editable: $e
389
+ }), A = Ot(G), Ze = en(), qe = s == null ? void 0 : s.remoteChanges[e.field], O = s == null ? void 0 : s.lockReasons[e.field], q = s == null ? void 0 : s.applyToLines[e.field], L = un(), Ie = (L == null ? void 0 : L.applied(e.field)) ?? !1, Te = (L == null ? void 0 : L.hintFor(e.field)) ?? null, ue = Xt(L, e.field, $e), me = () => {
390
+ var t, n;
391
+ return ((t = de.current) == null ? void 0 : t.querySelector(Ue)) ?? ((n = G.current) == null ? void 0 : n.querySelector(Ue));
392
+ }, J = St(e._overrides, o, bn(e)), pe = !!(s != null && s.fromAutofill) && !!e._overrides && e._overrides[$t] === !0;
393
+ async function et() {
384
394
  var t;
385
- if (Q.perField) return Ve();
386
- V(!0);
395
+ if (J.perField) return tt();
396
+ z(!0);
387
397
  try {
388
- const r = await ie.request(
389
- xe("/ai/generate", {
390
- collection: o,
398
+ const n = await se.request(
399
+ ve("/ai/generate", {
400
+ collection: i,
391
401
  item_id: l !== "new" ? l : void 0,
392
402
  field: e.field
393
403
  })
394
404
  );
395
- ((t = r.data) == null ? void 0 : t.value) != null && p(e.field, r.data.value);
405
+ ((t = n.data) == null ? void 0 : t.value) != null && p(e.field, n.data.value);
396
406
  } catch {
397
407
  } finally {
398
- V(!1);
408
+ z(!1);
399
409
  }
400
410
  }
401
- async function Ve() {
402
- var r, h, k, j, T, F;
411
+ async function tt() {
412
+ var n, h, k, j, T, F;
403
413
  const t = {};
404
- for (const v of ((r = wt(e._overrides)) == null ? void 0 : r.tokens) ?? []) v in u && (t[v] = u[v]);
405
- V(!0);
414
+ for (const v of ((n = qt(e._overrides)) == null ? void 0 : n.tokens) ?? []) v in m && (t[v] = m[v]);
415
+ z(!0);
406
416
  try {
407
- const v = await ie.request(
408
- xe("/ai/field-fill", {
409
- collection: o,
417
+ const v = await se.request(
418
+ ve("/ai/field-fill", {
419
+ collection: i,
410
420
  layout_id: (s == null ? void 0 : s.layoutId) ?? null,
411
421
  field: e.field,
412
422
  item_id: l && l !== "new" ? l : null,
413
423
  values: t
414
424
  })
415
425
  ), _ = (h = v.data) == null ? void 0 : h.value;
416
- typeof _ == "string" && _ !== "" ? p(e.field, _) : K.info("The AI had nothing to write here"), (j = (k = v.data) == null ? void 0 : k.missing) != null && j.length && K.info(`Filled without ${v.data.missing.join(", ")} (empty or not visible to you)`);
426
+ typeof _ == "string" && _ !== "" ? p(e.field, _) : U.info("The AI had nothing to write here"), (j = (k = v.data) == null ? void 0 : k.missing) != null && j.length && U.info(`Filled without ${v.data.missing.join(", ")} (empty or not visible to you)`);
417
427
  } catch (v) {
418
428
  const _ = v;
419
- K.error(((F = (T = _ == null ? void 0 : _.response) == null ? void 0 : T.data) == null ? void 0 : F.error) ?? (_ == null ? void 0 : _.message) ?? "AI fill failed");
429
+ U.error(((F = (T = _ == null ? void 0 : _.response) == null ? void 0 : T.data) == null ? void 0 : F.error) ?? (_ == null ? void 0 : _.message) ?? "AI fill failed");
420
430
  } finally {
421
- V(!1);
431
+ z(!1);
422
432
  }
423
433
  }
424
- const A = Et(e.dependency_config), Le = A.flatMap((t) => {
425
- const r = f.find(
426
- (k) => k.one_collection === o && k.one_field === t.parent_field
434
+ const E = Wt(e.dependency_config), Ae = E.flatMap((t) => {
435
+ const n = f.find(
436
+ (k) => k.one_collection === i && k.one_field === t.parent_field
427
437
  );
428
- if (!r) return [];
429
- if (r.junction_field) return [{ rule: t, rel: r }];
438
+ if (!n) return [];
439
+ if (n.junction_field) return [{ rule: t, rel: n }];
430
440
  const h = f.find(
431
- (k) => k.many_collection === r.many_collection && k.id !== r.id
441
+ (k) => k.many_collection === n.many_collection && k.id !== n.id
432
442
  );
433
- return h != null && h.many_field ? [{ rule: t, rel: { ...r, junction_field: h.many_field } }] : [];
434
- }), ze = at({
435
- queries: Le.map(({ rel: t }) => ({
443
+ return h != null && h.many_field ? [{ rule: t, rel: { ...n, junction_field: h.many_field } }] : [];
444
+ }), nt = xt({
445
+ queries: Ae.map(({ rel: t }) => ({
436
446
  queryKey: ["m2m-items", t.many_collection, t.many_field, l],
437
- queryFn: () => ie.request(
438
- U(`/items/${t.many_collection}`, {
447
+ queryFn: () => se.request(
448
+ H(`/items/${t.many_collection}`, {
439
449
  filter: JSON.stringify({ [t.many_field]: { _eq: l } }),
440
450
  limit: 200,
441
451
  fields: `id,${t.junction_field}`
442
452
  })
443
- ).then((r) => r.data ?? []),
453
+ ).then((n) => n.data ?? []),
444
454
  enabled: !!l && l !== "new",
445
455
  staleTime: 3e4
446
456
  }))
447
- }), Ge = Object.fromEntries(
448
- Le.map(({ rule: t, rel: r }, h) => {
457
+ }), rt = Object.fromEntries(
458
+ Ae.map(({ rule: t, rel: n }, h) => {
449
459
  var T;
450
- const k = r.one_field ?? `${r.many_collection}.${r.junction_field}`, j = (g == null ? void 0 : g.getStagedUnlinks(k)) ?? /* @__PURE__ */ new Set();
460
+ const k = n.one_field ?? `${n.many_collection}.${n.junction_field}`, j = (g == null ? void 0 : g.getStagedUnlinks(k)) ?? /* @__PURE__ */ new Set();
451
461
  return [
452
462
  t.parent_field,
453
- (((T = ze[h]) == null ? void 0 : T.data) ?? []).filter((F) => !j.has(F.id)).map((F) => F[r.junction_field])
463
+ (((T = nt[h]) == null ? void 0 : T.data) ?? []).filter((F) => !j.has(F.id)).map((F) => F[n.junction_field])
454
464
  ];
455
465
  })
456
- ), Y = Nt()[e.field] ?? [];
457
- if (!De && (!b || !e.layout_assigned && (e.hidden || jt.has(e.field))))
466
+ ), X = Et()[e.field] ?? [];
467
+ if (!Ve && (!b || !e.layout_assigned && (e.hidden || Vt.has(e.field))))
458
468
  return null;
459
- const de = u[e.field] ?? null, J = Ut(e, He), S = J.label ?? he(e.field);
460
- ve.current = S !== "";
461
- const E = Ht(e), Re = E ? null : Wt(e), Qe = !E && !m && !e.readonly && ((Te = e._overrides) == null ? void 0 : Te.repeat_last) === !0, Ye = Ot(e, u), Je = (Ae = (qe = Pt(e.options)) == null ? void 0 : qe.auto_id) == null ? void 0 : Ae.pattern, w = (() => {
469
+ const he = m[e.field] ?? null, Z = tn(e, Ze), S = Z.label ?? ge(e.field);
470
+ Ne.current = S !== "";
471
+ const P = He(e), Ee = P ? null : nn(e), lt = !P && !u && !e.readonly && ((De = e._overrides) == null ? void 0 : De.repeat_last) === !0, at = Yt(e, m), ot = (Be = (Oe = zt(e.options)) == null ? void 0 : Oe.auto_id) == null ? void 0 : Be.pattern, w = (() => {
462
472
  const t = f.find(
463
- (h) => h.one_collection === o && h.one_field === e.field
473
+ (h) => h.one_collection === i && h.one_field === e.field
464
474
  );
465
475
  if (!t) return null;
466
476
  if (t.junction_field) return t;
467
- const r = f.find(
477
+ const n = f.find(
468
478
  (h) => h.many_collection === t.many_collection && h.id !== t.id
469
479
  );
470
- return r ? { ...t, junction_field: r.many_field } : null;
471
- })(), ce = w ? null : f.find((t) => t.many_collection === o && t.many_field === e.field) ?? null, ue = w ? f.find(
480
+ return n ? { ...t, junction_field: n.many_field } : null;
481
+ })(), xe = w ? null : f.find((t) => t.many_collection === i && t.many_field === e.field) ?? null, fe = w ? f.find(
472
482
  (t) => t.many_collection === w.many_collection && t.many_field === w.junction_field && t.id !== w.id
473
- ) ?? null : null, M = w ? w.one_field ?? `${w.many_collection}.${w.junction_field}` : null, $e = M ? (g == null ? void 0 : g.getStagedLinks(M)) ?? [] : [], Xe = w ? (ye.getQueryData([
483
+ ) ?? null : null, B = w ? w.one_field ?? `${w.many_collection}.${w.junction_field}` : null, Pe = B ? (g == null ? void 0 : g.getStagedLinks(B)) ?? [] : [], it = w ? (ke.getQueryData([
474
484
  "m2m-items",
475
485
  w.many_collection,
476
486
  w.many_field,
477
487
  l
478
- ]) ?? []).map((t) => t[w.junction_field]) : [], Ze = w ? $e[0] ?? Xe[0] ?? null : de, Ie = (ue == null ? void 0 : ue.one_collection) ?? (ce == null ? void 0 : ce.one_collection) ?? void 0, X = (t) => {
479
- var r;
480
- return ((C == null ? void 0 : C.collection) === o ? (r = C == null ? void 0 : C.fieldLabels) == null ? void 0 : r[t] : void 0) ?? he(String(t));
481
- }, R = Dt({
482
- rules: A,
488
+ ]) ?? []).map((t) => t[w.junction_field]) : [], st = w ? Pe[0] ?? it[0] ?? null : he, dt = (fe == null ? void 0 : fe.one_collection) ?? (xe == null ? void 0 : xe.one_collection) ?? void 0, I = (t) => {
489
+ var n;
490
+ return ((C == null ? void 0 : C.collection) === i ? (n = C == null ? void 0 : C.fieldLabels) == null ? void 0 : n[t] : void 0) ?? ge(String(t));
491
+ }, $ = Gt({
492
+ rules: E,
483
493
  // A parent whose value THIS field's own pick derived must not narrow this
484
494
  // field's options — otherwise picking a region locks the region picker
485
495
  // into the zone the pick itself filled, and cross-zone changes read as
486
496
  // "No results".
487
497
  skipParent: (t) => {
488
- var r;
489
- return ((r = g == null ? void 0 : g.getDerivedOrigin) == null ? void 0 : r.call(g, t)) === e.field;
498
+ var n;
499
+ return ((n = g == null ? void 0 : g.getDerivedOrigin) == null ? void 0 : n.call(g, t)) === e.field;
490
500
  },
491
501
  parentValue: (t) => {
492
- if (u[t] != null) return u[t];
493
- const r = f.find((v) => v.one_collection === o && v.one_field === t);
494
- if (!r) return null;
495
- let h = r;
502
+ if (m[t] != null) return m[t];
503
+ const n = f.find((v) => v.one_collection === i && v.one_field === t);
504
+ if (!n) return null;
505
+ let h = n;
496
506
  if (!h.junction_field) {
497
507
  const v = f.find(
498
- (_) => _.many_collection === r.many_collection && _.id !== r.id
508
+ (_) => _.many_collection === n.many_collection && _.id !== n.id
499
509
  );
500
- if (v != null && v.many_field) h = { ...r, junction_field: v.many_field };
510
+ if (v != null && v.many_field) h = { ...n, junction_field: v.many_field };
501
511
  else return null;
502
512
  }
503
- const k = h.one_field ?? `${h.many_collection}.${h.junction_field}`, j = (g == null ? void 0 : g.getStagedLinks(k)) ?? [], T = Ge[t] ?? [], F = [...new Set([...j, ...T].map((v) => String(v)))];
513
+ const k = h.one_field ?? `${h.many_collection}.${h.junction_field}`, j = (g == null ? void 0 : g.getStagedLinks(k)) ?? [], T = rt[t] ?? [], F = [...new Set([...j, ...T].map((v) => String(v)))];
504
514
  return F.length === 0 ? null : F.length === 1 ? F[0] : F;
505
515
  },
506
516
  parentOptionFilter: (t) => {
507
517
  var h;
508
- const r = (C == null ? void 0 : C.collection) === o ? (h = C.fieldOptionFilters) == null ? void 0 : h[t] : void 0;
509
- return r ? Zt(r, u, l) : void 0;
518
+ const n = (C == null ? void 0 : C.collection) === i ? (h = C.fieldOptionFilters) == null ? void 0 : h[t] : void 0;
519
+ return n ? mn(n, m, l) : void 0;
510
520
  }
511
- }), O = R.filter ? Jt(Oe, R.filter, Xt) : R.filter, B = R.satisfiedParents.map(X), me = R.satisfiedParents, et = R.unsatisfiedParents.length ? X(R.unsatisfiedParents[0]) : null, pe = R.missingRequiredParents, Se = pe.length ? X(pe[0]) : null;
512
- function tt() {
513
- const t = Fe.current;
521
+ }), M = $.filter ? dn(Ge, $.filter, cn) : $.filter, K = $.satisfiedParents.map(I), ye = $.satisfiedParents, ct = $.unsatisfiedParents.length ? I($.unsatisfiedParents[0]) : null, be = $.missingRequiredParents, je = be.length ? I(be[0]) : null;
522
+ function ut() {
523
+ const t = Se.current;
514
524
  if (t && t.src === e) return t.value;
515
- const r = { ...e, readonly: !0 };
516
- return Fe.current = { src: e, value: r }, r;
525
+ const n = { ...e, readonly: !0 };
526
+ return Se.current = { src: e, value: n }, n;
517
527
  }
518
- function nt() {
519
- const t = JSON.stringify([B, me]), r = Ne.current;
520
- if (r && r.sig === t && r.onChange === p) return r.value;
528
+ function mt() {
529
+ const t = JSON.stringify([K, ye]), n = Re.current;
530
+ if (n && n.sig === t && n.onChange === p) return n.value;
521
531
  const h = {
522
- labels: B,
523
- keys: me,
532
+ labels: K,
533
+ keys: ye,
524
534
  onClear: (k) => p(k, null)
525
535
  };
526
- return Ne.current = { sig: t, onChange: p, value: h }, h;
536
+ return Re.current = { sig: t, onChange: p, value: h }, h;
527
537
  }
528
- function rt() {
529
- for (const t of me) {
530
- const r = document.querySelector(`[data-field="${t}"]`);
531
- r && (r.scrollIntoView({ behavior: "smooth", block: "center" }), r.style.transition = "box-shadow 0.15s ease", r.style.boxShadow = "0 0 0 2px rgb(var(--nvr-cyan-rgb, 0 206 255)), 0 0 0 5px rgb(var(--nvr-cyan-rgb, 0 206 255) / 0.25)", r.style.borderRadius = "12px", setTimeout(() => {
532
- r.style.boxShadow = "none", setTimeout(() => {
533
- r.style.transition = "", r.style.borderRadius = "";
538
+ function pt() {
539
+ for (const t of ye) {
540
+ const n = document.querySelector(`[data-field="${t}"]`);
541
+ n && (n.scrollIntoView({ behavior: "smooth", block: "center" }), n.style.transition = "box-shadow 0.15s ease", n.style.boxShadow = "0 0 0 2px rgb(var(--nvr-cyan-rgb, 0 206 255)), 0 0 0 5px rgb(var(--nvr-cyan-rgb, 0 206 255) / 0.25)", n.style.borderRadius = "12px", setTimeout(() => {
542
+ n.style.boxShadow = "none", setTimeout(() => {
543
+ n.style.transition = "", n.style.borderRadius = "";
534
544
  }, 300);
535
545
  }, 900));
536
546
  }
537
547
  }
538
- const lt = () => {
539
- if (w && M) {
540
- for (const r of $e) g == null || g.unstageLink(M, r);
541
- const t = ye.getQueryData([
548
+ const ht = () => {
549
+ if (w && B) {
550
+ for (const n of Pe) g == null || g.unstageLink(B, n);
551
+ const t = ke.getQueryData([
542
552
  "m2m-items",
543
553
  w.many_collection,
544
554
  w.many_field,
545
555
  l
546
556
  ]) ?? [];
547
- for (const r of t) g == null || g.stageUnlink(M, r.id);
557
+ for (const n of t) g == null || g.stageUnlink(B, n.id);
548
558
  } else
549
559
  p(e.field, null);
550
560
  };
@@ -553,234 +563,272 @@ const jn = ft(function({
553
563
  /* @__PURE__ */ c(
554
564
  "div",
555
565
  {
556
- ref: oe,
566
+ ref: G,
557
567
  "data-field": e.field,
558
- "data-field-collection": o,
568
+ "data-field-collection": i,
559
569
  "data-field-interface": e.interface ?? void 0,
560
- "data-autofill-check": se ? "" : void 0,
561
- className: P(
570
+ "data-autofill-check": pe ? "" : void 0,
571
+ className: D(
562
572
  "group/fieldrow space-y-1.5",
563
- se && "rounded-md bg-amber-50/60 p-1.5 ring-1 ring-amber-300 dark:bg-amber-500/10 dark:ring-amber-500/40"
573
+ pe && "rounded-md bg-amber-50/60 p-1.5 ring-1 ring-amber-300 dark:bg-amber-500/10 dark:ring-amber-500/40"
564
574
  ),
565
- onContextMenu: Be,
566
- onKeyDown: Ke,
567
- onFocusCapture: q.onFocusCapture,
575
+ onContextMenu: Qe,
576
+ onKeyDown: Ye,
577
+ onFocusCapture: A.onFocusCapture,
568
578
  children: [
569
- Ue,
570
- A.length > 0 && /* @__PURE__ */ n(
571
- Mt,
579
+ Je,
580
+ E.length > 0 && /* @__PURE__ */ r(
581
+ Qt,
572
582
  {
573
- cascadeRules: A,
574
- cascadeFilter: O,
575
- currentValue: Ze,
576
- relatedCollection: Ie,
577
- missingRequiredParents: pe,
578
- onClear: lt
583
+ cascadeRules: E,
584
+ cascadeFilter: M,
585
+ currentValue: st,
586
+ relatedCollection: dt,
587
+ missingRequiredParents: be,
588
+ onClear: ht
579
589
  }
580
590
  ),
581
- (S !== "" || Y.length > 0) && /* @__PURE__ */ c("div", { className: "flex flex-wrap items-center gap-1.5 min-h-[1.5rem]", children: [
582
- S !== "" && /* @__PURE__ */ c(_t, { id: z, "data-field-label": !0, className: "text-sm font-medium", children: [
583
- /* @__PURE__ */ n(je, { text: S, collection: o }),
584
- e.required && /* @__PURE__ */ n("span", { className: "ml-0.5 text-destructive", children: "*" }),
585
- Vt(e) && /* @__PURE__ */ n(zt, {})
586
- ] }),
587
- J.note && /* @__PURE__ */ n(Z, { delayDuration: 100, children: /* @__PURE__ */ c(I, { children: [
588
- /* @__PURE__ */ n(ee, { asChild: !0, children: /* @__PURE__ */ n(ot, { className: "h-3.5 w-3.5 shrink-0 cursor-help text-slate-400 hover:text-slate-600" }) }),
589
- /* @__PURE__ */ n(te, { side: "top", className: "max-w-[240px] text-[12px]", children: (s == null ? void 0 : s.glossaryHelp) === !1 ? J.note : /* @__PURE__ */ n(je, { text: J.note, collection: o }) })
590
- ] }) }),
591
- !E && l && l !== "new" && /* @__PURE__ */ n(
592
- sn,
593
- {
594
- collection: o,
595
- itemId: l,
596
- field: e.field,
597
- onRestore: e.readonly ? void 0 : (t) => p(e.field, t)
598
- }
599
- ),
600
- !E && l && l !== "new" && /* @__PURE__ */ n(dn, { collection: o, itemId: l, field: e.field }),
601
- l && l !== "new" && Ye && /* @__PURE__ */ n(on, { collection: o, itemId: l, field: e.field }),
602
- Qe && /* @__PURE__ */ n(
603
- Gt,
604
- {
605
- collection: o,
606
- itemId: l,
607
- field: e.field,
608
- label: S || he(e.field),
609
- onFill: (t) => p(e.field, t)
610
- }
611
- ),
612
- !E && Q.show && !(Q.perField && (m || e.readonly)) && /* @__PURE__ */ c(
613
- "button",
614
- {
615
- type: "button",
616
- onClick: We,
617
- disabled: be,
618
- "data-ai-fill": Q.perField ? e.field : void 0,
619
- className: "inline-flex items-center gap-0.5 rounded px-1 py-0.5 text-[10px] font-medium text-nvr-cyan hover:bg-nvr-cyan/10 disabled:opacity-50 transition-colors",
620
- title: "Generate with AI",
621
- children: [
622
- be ? /* @__PURE__ */ n(st, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ n(dt, { className: "h-3 w-3" }),
623
- "AI"
624
- ]
625
- }
626
- ),
627
- se && /* @__PURE__ */ n(
628
- "span",
629
- {
630
- "data-tip": "People often change what the AI read from the document here — check it",
631
- className: "inline-flex items-center rounded px-1.5 py-0.5 text-[10.5px] font-medium text-amber-800 bg-amber-100 dark:bg-amber-500/15 dark:text-amber-200",
632
- children: "Check this"
633
- }
634
- ),
635
- x,
636
- $ && !m && !e.readonly && /* @__PURE__ */ c(
637
- "button",
638
- {
639
- type: "button",
640
- onClick: () => $.onApply(u[e.field] ?? null),
641
- disabled: u[e.field] == null || u[e.field] === "" || $.count === 0,
642
- "data-apply-to-lines": e.field,
643
- "data-tip": $.count === 0 ? "No lines yet — add lines first" : u[e.field] == null || u[e.field] === "" ? "Pick a value first" : $.count != null ? `Copy this value onto all ${$.count} lines (staged until you save)` : "Copy this value onto every line (staged until you save)",
644
- className: "inline-flex items-center gap-1 rounded border border-nvr-cyan/40 px-1.5 py-0.5 text-[10.5px] font-medium text-[#0e7490] transition-colors hover:bg-nvr-cyan/10 disabled:cursor-not-allowed disabled:opacity-40 dark:text-nvr-cyan",
645
- children: [
646
- $.label ?? "Apply to lines",
647
- " ↓"
648
- ]
649
- }
650
- ),
651
- Y.length > 0 && /* @__PURE__ */ n(Z, { delayDuration: 100, children: /* @__PURE__ */ c(I, { children: [
652
- /* @__PURE__ */ n(ee, { asChild: !0, children: /* @__PURE__ */ c("span", { className: "inline-flex items-center gap-1 rounded-full bg-amber-50 px-1.5 py-0.5 text-[10px] font-medium text-amber-700 border border-amber-200 dark:bg-amber-500/10 dark:text-amber-400 dark:border-amber-500/20 cursor-default", children: [
653
- /* @__PURE__ */ n("span", { className: "h-1.5 w-1.5 rounded-full bg-amber-400 shrink-0" }),
654
- "addendum"
655
- ] }) }),
656
- /* @__PURE__ */ c(te, { side: "top", className: "max-w-[220px] text-[12px]", children: [
657
- /* @__PURE__ */ c("p", { className: "font-medium mb-1", children: [
658
- "In active addendum",
659
- Y.length > 1 ? "s" : "",
660
- ":"
591
+ (S !== "" || X.length > 0) && /* @__PURE__ */ c(
592
+ "div",
593
+ {
594
+ className: "flex flex-wrap items-center gap-1.5 min-h-[1.5rem]",
595
+ "data-pd-row": ue ? "" : void 0,
596
+ children: [
597
+ S !== "" && /* @__PURE__ */ c(At, { id: Q, "data-field-label": !0, className: "text-sm font-medium", children: [
598
+ /* @__PURE__ */ r(Ke, { text: S, collection: i }),
599
+ e.required && /* @__PURE__ */ r("span", { className: "ml-0.5 text-destructive", children: "*" }),
600
+ rn(e) && /* @__PURE__ */ r(ln, {})
661
601
  ] }),
662
- Y.map((t) => /* @__PURE__ */ c("p", { className: "text-slate-400", children: [
663
- t.title,
664
- " ",
665
- /* @__PURE__ */ c("span", { className: "capitalize", children: [
666
- "(",
667
- t.status,
668
- ")"
669
- ] })
670
- ] }, t.id))
671
- ] })
672
- ] }) }),
673
- /* @__PURE__ */ n(
674
- At,
675
- {
676
- collection: o,
677
- kind: "field",
678
- name: e.field,
679
- label: S
680
- }
681
- ),
682
- (m || e.readonly) && D ? /* @__PURE__ */ n($t, { reason: D, onHover: s == null ? void 0 : s.onLockHover }) : m ? /* @__PURE__ */ n(Z, { delayDuration: 200, children: /* @__PURE__ */ c(I, { children: [
683
- /* @__PURE__ */ n(ee, { asChild: !0, children: /* @__PURE__ */ n("span", { className: "inline-flex items-center text-amber-400 dark:text-amber-500", children: /* @__PURE__ */ n(ct, { className: "h-3 w-3" }) }) }),
684
- /* @__PURE__ */ n(te, { side: "top", className: "text-[12px]", children: "This field is locked" })
685
- ] }) }) : null,
686
- A.length > 0 && (() => {
687
- const t = !!O && Object.keys(O).length > 0 && B.length > 0, r = A.map(
688
- (h) => X(String(h.parent_field))
689
- );
690
- return /* @__PURE__ */ n(Z, { delayDuration: 100, children: /* @__PURE__ */ c(I, { children: [
691
- /* @__PURE__ */ n(ee, { asChild: !0, children: /* @__PURE__ */ n(
602
+ Z.note && /* @__PURE__ */ r(ee, { delayDuration: 100, children: /* @__PURE__ */ c(te, { children: [
603
+ /* @__PURE__ */ r(ne, { asChild: !0, children: /* @__PURE__ */ r(yt, { className: "h-3.5 w-3.5 shrink-0 cursor-help text-slate-400 hover:text-slate-600" }) }),
604
+ /* @__PURE__ */ r(re, { side: "top", className: "max-w-[240px] text-[12px]", children: (s == null ? void 0 : s.glossaryHelp) === !1 ? Z.note : /* @__PURE__ */ r(Ke, { text: Z.note, collection: i }) })
605
+ ] }) }),
606
+ !P && l && l !== "new" && /* @__PURE__ */ r(
607
+ wn,
608
+ {
609
+ collection: i,
610
+ itemId: l,
611
+ field: e.field,
612
+ onRestore: e.readonly ? void 0 : (t) => p(e.field, t)
613
+ }
614
+ ),
615
+ !P && l && l !== "new" && /* @__PURE__ */ r(kn, { collection: i, itemId: l, field: e.field }),
616
+ l && l !== "new" && at && /* @__PURE__ */ r(vn, { collection: i, itemId: l, field: e.field }),
617
+ lt && /* @__PURE__ */ r(
618
+ an,
619
+ {
620
+ collection: i,
621
+ itemId: l,
622
+ field: e.field,
623
+ label: S || ge(e.field),
624
+ onFill: (t) => p(e.field, t)
625
+ }
626
+ ),
627
+ !P && J.show && !(J.perField && (u || e.readonly)) && /* @__PURE__ */ c(
628
+ "button",
629
+ {
630
+ type: "button",
631
+ onClick: et,
632
+ disabled: _e,
633
+ "data-ai-fill": J.perField ? e.field : void 0,
634
+ className: "inline-flex items-center gap-0.5 rounded px-1 py-0.5 text-[10px] font-medium text-nvr-cyan hover:bg-nvr-cyan/10 disabled:opacity-50 transition-colors",
635
+ title: "Generate with AI",
636
+ children: [
637
+ _e ? /* @__PURE__ */ r(bt, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ r(gt, { className: "h-3 w-3" }),
638
+ "AI"
639
+ ]
640
+ }
641
+ ),
642
+ pe && /* @__PURE__ */ r(
643
+ "span",
644
+ {
645
+ "data-tip": "People often change what the AI read from the document here — check it",
646
+ className: "inline-flex items-center rounded px-1.5 py-0.5 text-[10.5px] font-medium text-amber-800 bg-amber-100 dark:bg-amber-500/15 dark:text-amber-200",
647
+ children: "Check this"
648
+ }
649
+ ),
650
+ x,
651
+ q && !u && !e.readonly && /* @__PURE__ */ c(
692
652
  "button",
693
653
  {
694
654
  type: "button",
695
- "aria-label": `Show the fields that narrow ${S || "this list"}`,
696
- onClick: rt,
697
- className: P(
698
- "inline-flex items-center transition-colors",
699
- t ? "text-nvr-cyan hover:text-nvr-cyan" : "text-slate-300 hover:text-nvr-cyan dark:text-slate-600 dark:hover:text-nvr-cyan"
655
+ onClick: () => q.onApply(m[e.field] ?? null),
656
+ disabled: m[e.field] == null || m[e.field] === "" || q.count === 0,
657
+ "data-apply-to-lines": e.field,
658
+ "data-tip": q.count === 0 ? "No lines yet — add lines first" : m[e.field] == null || m[e.field] === "" ? "Pick a value first" : q.count != null ? `Copy this value onto all ${q.count} lines (staged until you save)` : "Copy this value onto every line (staged until you save)",
659
+ className: "inline-flex items-center gap-1 rounded border border-nvr-cyan/40 px-1.5 py-0.5 text-[10.5px] font-medium text-[#0e7490] transition-colors hover:bg-nvr-cyan/10 disabled:cursor-not-allowed disabled:opacity-40 dark:text-nvr-cyan",
660
+ children: [
661
+ q.label ?? "Apply to lines",
662
+ " ↓"
663
+ ]
664
+ }
665
+ ),
666
+ X.length > 0 && /* @__PURE__ */ r(ee, { delayDuration: 100, children: /* @__PURE__ */ c(te, { children: [
667
+ /* @__PURE__ */ r(ne, { asChild: !0, children: /* @__PURE__ */ c("span", { className: "inline-flex items-center gap-1 rounded-full bg-amber-50 px-1.5 py-0.5 text-[10px] font-medium text-amber-700 border border-amber-200 dark:bg-amber-500/10 dark:text-amber-400 dark:border-amber-500/20 cursor-default", children: [
668
+ /* @__PURE__ */ r("span", { className: "h-1.5 w-1.5 rounded-full bg-amber-400 shrink-0" }),
669
+ "addendum"
670
+ ] }) }),
671
+ /* @__PURE__ */ c(re, { side: "top", className: "max-w-[220px] text-[12px]", children: [
672
+ /* @__PURE__ */ c("p", { className: "font-medium mb-1", children: [
673
+ "In active addendum",
674
+ X.length > 1 ? "s" : "",
675
+ ":"
676
+ ] }),
677
+ X.map((t) => /* @__PURE__ */ c("p", { className: "text-slate-400", children: [
678
+ t.title,
679
+ " ",
680
+ /* @__PURE__ */ c("span", { className: "capitalize", children: [
681
+ "(",
682
+ t.status,
683
+ ")"
684
+ ] })
685
+ ] }, t.id))
686
+ ] })
687
+ ] }) }),
688
+ /* @__PURE__ */ r(
689
+ Ht,
690
+ {
691
+ collection: i,
692
+ kind: "field",
693
+ name: e.field,
694
+ label: S
695
+ }
696
+ ),
697
+ (u || e.readonly) && O ? /* @__PURE__ */ r(Bt, { reason: O, onHover: s == null ? void 0 : s.onLockHover }) : u ? /* @__PURE__ */ r(ee, { delayDuration: 200, children: /* @__PURE__ */ c(te, { children: [
698
+ /* @__PURE__ */ r(ne, { asChild: !0, children: /* @__PURE__ */ r("span", { className: "inline-flex items-center text-amber-400 dark:text-amber-500", children: /* @__PURE__ */ r(vt, { className: "h-3 w-3" }) }) }),
699
+ /* @__PURE__ */ r(re, { side: "top", className: "text-[12px]", children: "This field is locked" })
700
+ ] }) }) : null,
701
+ E.length > 0 && (() => {
702
+ const t = !!M && Object.keys(M).length > 0 && K.length > 0, n = E.map(
703
+ (h) => I(String(h.parent_field))
704
+ );
705
+ return /* @__PURE__ */ r(ee, { delayDuration: 100, children: /* @__PURE__ */ c(te, { children: [
706
+ /* @__PURE__ */ r(ne, { asChild: !0, children: /* @__PURE__ */ r(
707
+ "button",
708
+ {
709
+ type: "button",
710
+ "aria-label": `Show the fields that narrow ${S || "this list"}`,
711
+ onClick: pt,
712
+ className: D(
713
+ "inline-flex items-center transition-colors",
714
+ t ? "text-nvr-cyan hover:text-nvr-cyan" : "text-slate-300 hover:text-nvr-cyan dark:text-slate-600 dark:hover:text-nvr-cyan"
715
+ ),
716
+ children: /* @__PURE__ */ r(wt, { className: "h-3 w-3" })
717
+ }
718
+ ) }),
719
+ /* @__PURE__ */ r(re, { side: "top", className: "text-[12px]", children: t ? `Filtered by ${K.join(", ")} — click to highlight` : `Options filter by ${n.join(", ")} once set` })
720
+ ] }) });
721
+ })(),
722
+ ue && // Right-anchored: the personal-default control flush with the field's right edge
723
+ // (it carries Make / Update / Clear itself — no ⋯ button; right-click and
724
+ // Shift+F10 still open the field menu). The slot keeps one box whatever it shows,
725
+ // so nothing to its left moves.
726
+ /* @__PURE__ */ r("span", { className: "ml-auto inline-flex shrink-0 items-center gap-1", children: /* @__PURE__ */ r(
727
+ Zt,
728
+ {
729
+ field: e.field,
730
+ label: S,
731
+ state: ue,
732
+ confirmOpen: ce === "make" || ce === "update" ? ce : null,
733
+ onConfirm: (t, n) => (
734
+ // After a save the button becomes "Your default": focus goes to the field.
735
+ Xe(t, me, n)
700
736
  ),
701
- children: /* @__PURE__ */ n(ut, { className: "h-3 w-3" })
737
+ onUndo: () => {
738
+ L == null || L.undo(e.field), requestAnimationFrame(() => {
739
+ var t;
740
+ return (t = me()) == null ? void 0 : t.focus();
741
+ });
742
+ },
743
+ onCleared: () => (
744
+ // The Clear button is gone (and not a tab stop): focus goes to the field.
745
+ requestAnimationFrame(() => {
746
+ var t;
747
+ return (t = me()) == null ? void 0 : t.focus();
748
+ })
749
+ )
702
750
  }
703
- ) }),
704
- /* @__PURE__ */ n(te, { side: "top", className: "text-[12px]", children: t ? `Filtered by ${B.join(", ")} — click to highlight` : `Options filter by ${r.join(", ")} once set` })
705
- ] }) });
706
- })()
707
- ] }),
708
- q.editor && !m && /* @__PURE__ */ n(
709
- St,
751
+ ) })
752
+ ]
753
+ }
754
+ ),
755
+ A.editor && !u && /* @__PURE__ */ r(
756
+ Mt,
710
757
  {
711
- editor: q.editor,
712
- confirming: q.confirming,
713
- onConfirm: q.confirm,
714
- onCancel: q.cancel
758
+ editor: A.editor,
759
+ confirming: A.confirming,
760
+ onConfirm: A.confirm,
761
+ onCancel: A.cancel
715
762
  }
716
763
  ),
717
- H ?? /* @__PURE__ */ n(
764
+ W ?? /* @__PURE__ */ r(
718
765
  "div",
719
766
  {
720
- ref: ge,
721
- className: P(m && !W && "cursor-not-allowed"),
722
- "data-tip": (m || e.readonly) && D ? D : void 0,
723
- onPointerEnter: (m || e.readonly) && D ? s == null ? void 0 : s.onLockHover : void 0,
724
- children: /* @__PURE__ */ n(
767
+ ref: de,
768
+ className: D(u && !V && "cursor-not-allowed"),
769
+ "data-tip": (u || e.readonly) && O ? O : void 0,
770
+ onPointerEnter: (u || e.readonly) && O ? s == null ? void 0 : s.onLockHover : void 0,
771
+ children: /* @__PURE__ */ r(
725
772
  "div",
726
773
  {
727
- ref: ke,
728
- className: P(
774
+ ref: Ce,
775
+ className: D(
729
776
  // A locked FILE field stays interactive: its chips keep the
730
777
  // download link and preview click (the component itself hides
731
778
  // upload/replace/remove when readonly) — blocking pointer events
732
779
  // made attachments unopenable on every locked form (addendum
733
780
  // view, terminal states).
734
- m && !W && "pointer-events-none opacity-60",
781
+ u && !V && "pointer-events-none opacity-60",
735
782
  // The ring lands with a 2px shake so the eye finds the field;
736
783
  // the animation runs once when the class is added.
737
784
  N && "nvr-shake ring-1 ring-red-400 rounded-md",
738
- ae && "nvr-autofill-glow"
785
+ ie && "nvr-autofill-glow"
739
786
  ),
740
- children: E ? /* @__PURE__ */ n(Qt, { field: e, values: u }) : Je ? /* @__PURE__ */ n(
741
- Ft,
787
+ children: P ? /* @__PURE__ */ r(on, { field: e, values: m }) : ot ? /* @__PURE__ */ r(
788
+ Pt,
742
789
  {
743
- collection: o,
790
+ collection: i,
744
791
  field: e,
745
- draft: u,
792
+ draft: m,
746
793
  itemId: l
747
794
  }
748
795
  ) : y ? y({
749
796
  field: e,
750
- value: de,
751
- onChange: _e,
752
- disabled: m,
753
- collection: o,
797
+ value: he,
798
+ onChange: Le,
799
+ disabled: u,
800
+ collection: i,
754
801
  itemId: l,
755
802
  relations: f,
756
- cascadeFilter: O,
757
- unsatisfiedParentLabel: et,
758
- requiredParentLabel: Se
759
- }) : /* @__PURE__ */ n(
760
- qt,
803
+ cascadeFilter: M,
804
+ unsatisfiedParentLabel: ct,
805
+ requiredParentLabel: je
806
+ }) : /* @__PURE__ */ r(
807
+ Ut,
761
808
  {
762
- field: m && W ? tt() : e,
763
- value: de,
764
- onChange: _e,
809
+ field: u && V ? ut() : e,
810
+ value: he,
811
+ onChange: Le,
765
812
  relations: f,
766
- collection: o,
813
+ collection: i,
767
814
  itemId: l,
768
- cascadeFilter: O,
769
- requiredParentLabel: Se,
770
- narrowedBy: B.length > 0 ? nt() : void 0,
771
- onCountChange: a ? Me : void 0
815
+ cascadeFilter: M,
816
+ requiredParentLabel: je,
817
+ narrowedBy: K.length > 0 ? mt() : void 0,
818
+ onCountChange: a ? ze : void 0
772
819
  }
773
820
  )
774
821
  },
775
- ae ?? 0
822
+ ie ?? 0
776
823
  )
777
824
  }
778
825
  ),
779
- Re && /* @__PURE__ */ n(Yt, { value: u[e.field], config: Re }),
780
- Ce && /* @__PURE__ */ n(
781
- Tt,
826
+ Ee && /* @__PURE__ */ r(sn, { value: m[e.field], config: Ee }),
827
+ Te && !Ie && /* @__PURE__ */ r(It, { field: e.field, text: Te }),
828
+ qe && /* @__PURE__ */ r(
829
+ Kt,
782
830
  {
783
- change: Ce,
831
+ change: qe,
784
832
  onDismiss: () => s == null ? void 0 : s.dismissRemoteChange(e.field),
785
833
  onTakeTheirs: s != null && s.takeRemoteChange ? () => {
786
834
  var t;
@@ -794,7 +842,7 @@ const jn = ft(function({
794
842
  );
795
843
  });
796
844
  export {
797
- jn as FieldRow,
798
- En as lineageSummary,
799
- an as useFieldLineage
845
+ Zn as FieldRow,
846
+ Xn as lineageSummary,
847
+ gn as useFieldLineage
800
848
  };