@nivaro/react 0.3.24 → 0.3.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +45 -26
- package/dist/shared/components/FilePreviewLightbox.js +56 -35
- package/dist/shared/components/ItemEditForm.js +4309 -4263
- package/dist/shared/components/PageRenderer.js +63 -62
- package/dist/shared/components/RecordReadView.js +229 -229
- package/dist/shared/components/ReportView.js +123 -120
- package/dist/shared/components/ai/AiMarkdown.js +168 -148
- package/dist/shared/components/chat/RoomParts.js +120 -119
- package/dist/shared/components/chat/chat-core.js +228 -224
- package/dist/shared/components/item-edit/FieldRenderer.js +333 -333
- package/dist/shared/components/item-edit/FieldRow.js +413 -394
- package/dist/shared/components/item-edit/GroupSection.js +637 -635
- package/dist/shared/components/item-edit/InlineGridField.js +89 -90
- package/dist/shared/components/item-edit/QuickPicker.js +9 -9
- package/dist/shared/components/item-edit/RawEditSheet.js +80 -79
- package/dist/shared/components/item-edit/RowMatchPanel.js +1 -1
- package/dist/shared/components/item-edit/m2m-invalidate.js +19 -0
- package/dist/shared/components/item-edit/record-lookups.js +15 -0
- package/dist/shared/components/item-edit/render-stability.js +147 -0
- package/dist/shared/components/layout-editor/FormMapButton.js +5 -4
- package/dist/shared/lib/safe-href.js +10 -0
- package/dist/shared/lib/socket-realtime.js +107 -78
- package/package.json +6 -6
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useQueryClient as
|
|
3
|
-
import { Info as
|
|
4
|
-
import { useState as
|
|
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
5
|
import { toast as K } from "sonner";
|
|
6
|
-
import { useParentDraft as
|
|
7
|
-
import { showsAiButton as
|
|
8
|
-
import { get as
|
|
9
|
-
import { titleCase as
|
|
10
|
-
import { GlossaryLabel as
|
|
11
|
-
import { Label as
|
|
12
|
-
import { TooltipProvider as
|
|
13
|
-
import { useAddendumFields as
|
|
14
|
-
import { AutoIdPreviewField as
|
|
15
|
-
import { useFieldAffordances as
|
|
16
|
-
import { FieldRenderer as
|
|
17
|
-
import { FormHelpVideoButton as
|
|
18
|
-
import { getCascadeFilters as
|
|
19
|
-
import { isDerivedForRecord as
|
|
20
|
-
import { useM2MStaging as
|
|
21
|
-
import { usePlacementTextContext as
|
|
22
|
-
import {
|
|
23
|
-
|
|
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([
|
|
24
25
|
"input",
|
|
25
26
|
"textarea",
|
|
26
27
|
"wysiwyg",
|
|
@@ -28,7 +29,7 @@ const Bt = /* @__PURE__ */ new Set(["integer", "float", "decimal", "bigInteger",
|
|
|
28
29
|
"input-rich-text-html",
|
|
29
30
|
"rich_text",
|
|
30
31
|
"extension-editorjs"
|
|
31
|
-
]),
|
|
32
|
+
]), nn = /* @__PURE__ */ new Set([
|
|
32
33
|
"relation-m2o",
|
|
33
34
|
"relation-m2m",
|
|
34
35
|
"select-multiple-m2m",
|
|
@@ -39,220 +40,220 @@ const Bt = /* @__PURE__ */ new Set(["integer", "float", "decimal", "bigInteger",
|
|
|
39
40
|
"file",
|
|
40
41
|
"files",
|
|
41
42
|
"image"
|
|
42
|
-
]),
|
|
43
|
-
function
|
|
44
|
-
const
|
|
45
|
-
return
|
|
43
|
+
]), rn = /* @__PURE__ */ new Set(["file", "file-image", "files-m2m", "files", "image"]);
|
|
44
|
+
function ln(d) {
|
|
45
|
+
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));
|
|
46
47
|
}
|
|
47
|
-
function
|
|
48
|
-
const
|
|
49
|
-
return
|
|
50
|
-
queryKey: ["field-lineage",
|
|
51
|
-
queryFn: () =>
|
|
52
|
-
|
|
53
|
-
).then((
|
|
48
|
+
function an(d, e, u, p) {
|
|
49
|
+
const f = le();
|
|
50
|
+
return ne({
|
|
51
|
+
queryKey: ["field-lineage", d, e, u],
|
|
52
|
+
queryFn: () => f.request(
|
|
53
|
+
U(`/lineage/${d}/${encodeURIComponent(e)}/${u}`)
|
|
54
|
+
).then((o) => o.data),
|
|
54
55
|
enabled: p,
|
|
55
56
|
staleTime: 3e4
|
|
56
57
|
});
|
|
57
58
|
}
|
|
58
|
-
function
|
|
59
|
-
var
|
|
60
|
-
if (
|
|
61
|
-
const
|
|
62
|
-
return `= ${
|
|
63
|
-
var
|
|
64
|
-
return
|
|
59
|
+
function En(d, e = "rows") {
|
|
60
|
+
var l, N, b;
|
|
61
|
+
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);
|
|
63
|
+
return `= ${d.formula.replace(/item\.([A-Za-z_][A-Za-z0-9_]*)/g, (y, a) => {
|
|
64
|
+
var x;
|
|
65
|
+
return m((x = d.inputs) == null ? void 0 : x[a]);
|
|
65
66
|
}).replace(/\s*-\s*/g, " − ").replace(/\s*\*\s*/g, " × ").replace(/\s*\/\s*/g, " ÷ ")}`;
|
|
66
67
|
}
|
|
67
|
-
if (!
|
|
68
|
-
const
|
|
68
|
+
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) => {
|
|
69
70
|
var y;
|
|
70
|
-
return
|
|
71
|
-
}, 0),
|
|
72
|
-
var
|
|
73
|
-
return (
|
|
74
|
-
})) == null ? void 0 :
|
|
75
|
-
return p &&
|
|
76
|
-
`${p} excluded${
|
|
77
|
-
),
|
|
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(
|
|
77
|
+
`${p} excluded${f ? ` (${f.replace(/^does not match: /, "")})` : ""}`
|
|
78
|
+
), o.join(" · ");
|
|
78
79
|
}
|
|
79
|
-
function
|
|
80
|
-
collection:
|
|
81
|
-
itemId:
|
|
82
|
-
field:
|
|
80
|
+
function on({
|
|
81
|
+
collection: d,
|
|
82
|
+
itemId: e,
|
|
83
|
+
field: u
|
|
83
84
|
}) {
|
|
84
|
-
const [p,
|
|
85
|
-
|
|
85
|
+
const [p, f] = fe(!1), o = L(null), { data: l, isLoading: N } = an(d, e, u, p);
|
|
86
|
+
re(() => {
|
|
86
87
|
if (!p) return;
|
|
87
|
-
const
|
|
88
|
+
const i = (y) => {
|
|
88
89
|
var a;
|
|
89
|
-
(a =
|
|
90
|
+
(a = o.current) != null && a.contains(y.target) || f(!1);
|
|
90
91
|
};
|
|
91
|
-
return window.addEventListener("mousedown",
|
|
92
|
+
return window.addEventListener("mousedown", i), () => window.removeEventListener("mousedown", i);
|
|
92
93
|
}, [p]);
|
|
93
|
-
const
|
|
94
|
-
return /* @__PURE__ */
|
|
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: [
|
|
95
96
|
/* @__PURE__ */ n(
|
|
96
97
|
"button",
|
|
97
98
|
{
|
|
98
99
|
type: "button",
|
|
99
|
-
onClick: () =>
|
|
100
|
+
onClick: () => f((i) => !i),
|
|
100
101
|
title: "Where does this number come from?",
|
|
101
102
|
className: P(
|
|
102
103
|
"inline-flex items-center rounded p-0.5 transition-opacity",
|
|
103
104
|
p ? "text-nvr-cyan opacity-100" : "text-slate-400 hover:text-nvr-cyan dark:text-slate-300 dark:hover:text-nvr-cyan"
|
|
104
105
|
),
|
|
105
106
|
"data-field-lineage": !0,
|
|
106
|
-
children: /* @__PURE__ */ n(
|
|
107
|
+
children: /* @__PURE__ */ n(xt, { className: "h-3 w-3" })
|
|
107
108
|
}
|
|
108
109
|
),
|
|
109
|
-
p && /* @__PURE__ */
|
|
110
|
+
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: [
|
|
110
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" }),
|
|
111
|
-
|
|
112
|
-
(
|
|
113
|
-
/* @__PURE__ */ n("p", { className: "font-mono text-[11px] text-slate-600 dark:text-slate-300", children:
|
|
114
|
-
Object.entries(
|
|
115
|
-
/* @__PURE__ */ n("span", { className: "font-mono", children:
|
|
112
|
+
N && /* @__PURE__ */ n("p", { className: "px-1 py-2 text-[11.5px] text-slate-400", children: "Loading…" }),
|
|
113
|
+
(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 }),
|
|
116
117
|
" = ",
|
|
117
|
-
|
|
118
|
-
] },
|
|
119
|
-
/* @__PURE__ */
|
|
118
|
+
b(y)
|
|
119
|
+
] }, i)),
|
|
120
|
+
/* @__PURE__ */ c("p", { className: "pt-1 text-[11.5px] font-medium text-slate-700 dark:text-slate-200", children: [
|
|
120
121
|
"= ",
|
|
121
|
-
|
|
122
|
+
b(l.stored_value)
|
|
122
123
|
] })
|
|
123
124
|
] }),
|
|
124
|
-
(
|
|
125
|
+
(l == null ? void 0 : l.kind) === "rollup" && (l.sources ?? []).map((i, y) => {
|
|
125
126
|
var a;
|
|
126
|
-
return /* @__PURE__ */
|
|
127
|
-
/* @__PURE__ */
|
|
128
|
-
(
|
|
129
|
-
|
|
127
|
+
return /* @__PURE__ */ c("div", { className: "mb-1.5", children: [
|
|
128
|
+
/* @__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}` : "",
|
|
130
131
|
" across ",
|
|
131
|
-
|
|
132
|
-
|
|
132
|
+
i.collection,
|
|
133
|
+
i.filtered ? " (filtered)" : ""
|
|
133
134
|
] }),
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
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(
|
|
137
138
|
"div",
|
|
138
139
|
{
|
|
139
140
|
className: "flex items-baseline gap-2 rounded px-1 py-0.5 text-[11.5px] hover:bg-slate-50 dark:hover:bg-muted",
|
|
140
141
|
children: [
|
|
141
|
-
/* @__PURE__ */ n("span", { className: "min-w-0 flex-1 truncate text-slate-600 dark:text-slate-300", children:
|
|
142
|
-
/* @__PURE__ */ n("span", { className: "shrink-0 font-mono tabular-nums text-slate-800 dark:text-slate-100", 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) }),
|
|
143
144
|
/* @__PURE__ */ n(
|
|
144
145
|
"span",
|
|
145
146
|
{
|
|
146
147
|
className: "w-[88px] shrink-0 truncate text-right text-[10px] text-slate-400",
|
|
147
|
-
"data-tip":
|
|
148
|
-
children:
|
|
148
|
+
"data-tip": x.updated_at ? `${x.updated_by ?? "unknown"} · ${new Date(x.updated_at).toLocaleString()}` : void 0,
|
|
149
|
+
children: x.updated_by ?? ""
|
|
149
150
|
}
|
|
150
151
|
)
|
|
151
152
|
]
|
|
152
153
|
},
|
|
153
|
-
|
|
154
|
+
x.id
|
|
154
155
|
)) }),
|
|
155
|
-
|
|
156
|
-
|
|
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: [
|
|
157
158
|
"subtotal ",
|
|
158
|
-
|
|
159
|
+
b(i.subtotal)
|
|
159
160
|
] }),
|
|
160
|
-
(((a =
|
|
161
|
-
/* @__PURE__ */
|
|
162
|
-
|
|
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: [
|
|
162
|
+
/* @__PURE__ */ c("p", { className: "text-[10.5px] text-slate-500 dark:text-muted-foreground", children: [
|
|
163
|
+
i.excluded.length,
|
|
163
164
|
" excluded —",
|
|
164
165
|
" ",
|
|
165
|
-
|
|
166
|
+
i.excluded[0].reason.replace(/^does not match: /, "")
|
|
166
167
|
] }),
|
|
167
|
-
|
|
168
|
+
i.excluded.slice(0, 8).map((x) => /* @__PURE__ */ c(
|
|
168
169
|
"div",
|
|
169
170
|
{
|
|
170
171
|
className: "flex items-baseline gap-2 px-0.5 text-[11px] text-slate-400",
|
|
171
172
|
children: [
|
|
172
|
-
/* @__PURE__ */ n("span", { className: "min-w-0 flex-1 truncate line-through decoration-slate-300", children:
|
|
173
|
-
/* @__PURE__ */ n("span", { className: "shrink-0 font-mono tabular-nums", 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) })
|
|
174
175
|
]
|
|
175
176
|
},
|
|
176
|
-
|
|
177
|
+
x.id
|
|
177
178
|
)),
|
|
178
|
-
|
|
179
|
+
i.excluded.length > 8 && /* @__PURE__ */ c("p", { className: "px-0.5 text-[10.5px] text-slate-400", children: [
|
|
179
180
|
"+",
|
|
180
|
-
|
|
181
|
+
i.excluded.length - 8,
|
|
181
182
|
" more"
|
|
182
183
|
] })
|
|
183
184
|
] })
|
|
184
185
|
] }, y);
|
|
185
186
|
}),
|
|
186
|
-
(
|
|
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: [
|
|
187
188
|
"stored ",
|
|
188
|
-
m
|
|
189
|
+
b(m),
|
|
189
190
|
(() => {
|
|
190
|
-
const
|
|
191
|
-
return (
|
|
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" });
|
|
192
193
|
})()
|
|
193
194
|
] })
|
|
194
195
|
] })
|
|
195
196
|
] });
|
|
196
197
|
}
|
|
197
|
-
function
|
|
198
|
-
collection:
|
|
199
|
-
itemId:
|
|
200
|
-
field:
|
|
198
|
+
function sn({
|
|
199
|
+
collection: d,
|
|
200
|
+
itemId: e,
|
|
201
|
+
field: u,
|
|
201
202
|
formatValue: p,
|
|
202
|
-
onRestore:
|
|
203
|
+
onRestore: f
|
|
203
204
|
}) {
|
|
204
|
-
const
|
|
205
|
-
queryKey: ["field-value-history",
|
|
206
|
-
queryFn: () =>
|
|
207
|
-
enabled:
|
|
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 ?? []),
|
|
208
|
+
enabled: l,
|
|
208
209
|
staleTime: 6e4
|
|
209
210
|
});
|
|
210
|
-
|
|
211
|
-
if (!
|
|
212
|
-
const a = (
|
|
213
|
-
var
|
|
214
|
-
(
|
|
211
|
+
re(() => {
|
|
212
|
+
if (!l) return;
|
|
213
|
+
const a = (x) => {
|
|
214
|
+
var H;
|
|
215
|
+
(H = b.current) != null && H.contains(x.target) || N(!1);
|
|
215
216
|
};
|
|
216
217
|
return window.addEventListener("mousedown", a), () => window.removeEventListener("mousedown", a);
|
|
217
|
-
}, [
|
|
218
|
-
const y = (a,
|
|
219
|
-
return /* @__PURE__ */
|
|
218
|
+
}, [l]);
|
|
219
|
+
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
|
+
return /* @__PURE__ */ c("div", { ref: b, className: "relative inline-flex", children: [
|
|
220
221
|
/* @__PURE__ */ n(
|
|
221
222
|
"button",
|
|
222
223
|
{
|
|
223
224
|
type: "button",
|
|
224
|
-
onClick: () =>
|
|
225
|
+
onClick: () => N((a) => !a),
|
|
225
226
|
title: "Value history",
|
|
226
227
|
className: P(
|
|
227
228
|
"inline-flex items-center rounded p-0.5 transition-opacity",
|
|
228
|
-
|
|
229
|
+
l ? "text-nvr-cyan opacity-100" : "text-slate-400 hover:text-nvr-cyan dark:text-slate-300 dark:hover:text-nvr-cyan"
|
|
229
230
|
),
|
|
230
231
|
"data-field-history": !0,
|
|
231
|
-
children: /* @__PURE__ */ n(
|
|
232
|
+
children: /* @__PURE__ */ n(mt, { className: "h-3 w-3" })
|
|
232
233
|
}
|
|
233
234
|
),
|
|
234
|
-
|
|
235
|
+
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: [
|
|
235
236
|
/* @__PURE__ */ n("p", { className: "mb-1 px-1 text-[10px] font-semibold uppercase tracking-wide text-slate-400", children: "Value history" }),
|
|
236
|
-
|
|
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(
|
|
237
238
|
"div",
|
|
238
239
|
{
|
|
239
240
|
className: "rounded px-1 py-1 text-[11.5px] leading-snug hover:bg-slate-50 dark:hover:bg-muted",
|
|
240
241
|
children: [
|
|
241
|
-
/* @__PURE__ */
|
|
242
|
+
/* @__PURE__ */ c("span", { className: "flex items-baseline justify-between gap-2", children: [
|
|
242
243
|
/* @__PURE__ */ n("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: y(a.value, a.display) }),
|
|
243
|
-
|
|
244
|
+
f && x > 0 && /* @__PURE__ */ n(
|
|
244
245
|
"button",
|
|
245
246
|
{
|
|
246
247
|
type: "button",
|
|
247
248
|
onClick: () => {
|
|
248
|
-
|
|
249
|
+
f(a.value ?? null), N(!1);
|
|
249
250
|
},
|
|
250
251
|
className: "shrink-0 rounded border border-slate-200 px-1.5 py-px text-[10px] text-slate-500 hover:border-nvr-cyan/60 hover:text-nvr-navy dark:border-border dark:hover:text-nvr-cyan",
|
|
251
252
|
children: "Restore"
|
|
252
253
|
}
|
|
253
254
|
)
|
|
254
255
|
] }),
|
|
255
|
-
/* @__PURE__ */
|
|
256
|
+
/* @__PURE__ */ c("span", { className: "block text-[10.5px] text-slate-400", children: [
|
|
256
257
|
a.action === "create" ? "initial value" : "changed",
|
|
257
258
|
a.timestamp ? ` · ${new Date(a.timestamp).toLocaleString()}` : "",
|
|
258
259
|
a.user_name ? ` · ${a.user_name}` : "",
|
|
@@ -264,246 +265,268 @@ function Yt({
|
|
|
264
265
|
}
|
|
265
266
|
)
|
|
266
267
|
] }),
|
|
267
|
-
a.note && /* @__PURE__ */
|
|
268
|
+
a.note && /* @__PURE__ */ c("span", { className: "block text-[10.5px] italic text-slate-500 dark:text-slate-400", children: [
|
|
268
269
|
"“",
|
|
269
270
|
a.note,
|
|
270
271
|
"”"
|
|
271
272
|
] })
|
|
272
273
|
]
|
|
273
274
|
},
|
|
274
|
-
|
|
275
|
+
x
|
|
275
276
|
)) })
|
|
276
277
|
] })
|
|
277
278
|
] });
|
|
278
279
|
}
|
|
279
|
-
function
|
|
280
|
-
collection:
|
|
281
|
-
itemId:
|
|
282
|
-
field:
|
|
280
|
+
function dn({
|
|
281
|
+
collection: d,
|
|
282
|
+
itemId: e,
|
|
283
|
+
field: u
|
|
283
284
|
}) {
|
|
284
|
-
const p =
|
|
285
|
+
const p = le(), f = Pe(), { data: o } = ne({
|
|
285
286
|
queryKey: ["field-watch-config"],
|
|
286
|
-
queryFn: () => p.request(
|
|
287
|
+
queryFn: () => p.request(U("/field-watches/config")).then((i) => i.data).catch(() => ({ enabled: !1 })),
|
|
287
288
|
staleTime: 5 * 6e4
|
|
288
|
-
}),
|
|
289
|
-
queryKey:
|
|
290
|
-
queryFn: () => p.request(
|
|
291
|
-
enabled: !!(
|
|
289
|
+
}), l = ["field-watch-self", d, e], { data: N = [] } = ne({
|
|
290
|
+
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),
|
|
292
293
|
staleTime: 6e4
|
|
293
|
-
}),
|
|
294
|
-
mutationFn: () =>
|
|
295
|
-
|
|
296
|
-
`/field-watches/self?collection=${encodeURIComponent(
|
|
294
|
+
}), b = N.includes(u), m = it({
|
|
295
|
+
mutationFn: () => b ? p.request(
|
|
296
|
+
kt(
|
|
297
|
+
`/field-watches/self?collection=${encodeURIComponent(d)}&field=${encodeURIComponent(u)}&item_id=${encodeURIComponent(e)}`
|
|
297
298
|
)
|
|
298
|
-
) : p.request(
|
|
299
|
+
) : p.request(xe("/field-watches/self", { collection: d, field: u, item_id: e })),
|
|
299
300
|
onSuccess: () => {
|
|
300
|
-
|
|
301
|
-
|
|
301
|
+
f.invalidateQueries({ queryKey: l }), K.success(
|
|
302
|
+
b ? "No longer watching this field" : "Watching — you will be notified when it changes"
|
|
302
303
|
);
|
|
303
304
|
},
|
|
304
305
|
onError: () => K.error("Could not update the watch")
|
|
305
306
|
});
|
|
306
|
-
return
|
|
307
|
+
return o != null && o.enabled ? /* @__PURE__ */ n(
|
|
307
308
|
"button",
|
|
308
309
|
{
|
|
309
310
|
type: "button",
|
|
310
|
-
onClick: () =>
|
|
311
|
-
title:
|
|
312
|
-
"data-field-watch":
|
|
313
|
-
className: `rounded p-0.5 transition-colors ${
|
|
314
|
-
children:
|
|
311
|
+
onClick: () => m.mutate(),
|
|
312
|
+
title: b ? "Stop watching this field on this record" : "Watch this field on this record",
|
|
313
|
+
"data-field-watch": u,
|
|
314
|
+
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" })
|
|
315
316
|
}
|
|
316
317
|
) : null;
|
|
317
318
|
}
|
|
318
|
-
function
|
|
319
|
-
return
|
|
319
|
+
function cn(d) {
|
|
320
|
+
return d ? d.querySelector(
|
|
320
321
|
'input:not([type=hidden]), textarea, [role="combobox"], [contenteditable="true"]'
|
|
321
|
-
) ??
|
|
322
|
+
) ?? d.querySelector("button") : null;
|
|
322
323
|
}
|
|
323
|
-
|
|
324
|
+
const jn = ft(function({
|
|
324
325
|
field: e,
|
|
325
|
-
draft:
|
|
326
|
-
onChange:
|
|
327
|
-
relations:
|
|
328
|
-
collection:
|
|
329
|
-
itemId:
|
|
330
|
-
error:
|
|
331
|
-
visible:
|
|
326
|
+
draft: u,
|
|
327
|
+
onChange: p,
|
|
328
|
+
relations: f,
|
|
329
|
+
collection: o,
|
|
330
|
+
itemId: l,
|
|
331
|
+
error: N,
|
|
332
|
+
visible: b,
|
|
332
333
|
locked: m,
|
|
333
|
-
layoutAiEnabled:
|
|
334
|
-
renderField:
|
|
335
|
-
onCountChange:
|
|
336
|
-
swapButton:
|
|
337
|
-
swapContent:
|
|
338
|
-
forceVisible:
|
|
334
|
+
layoutAiEnabled: i,
|
|
335
|
+
renderField: y,
|
|
336
|
+
onCountChange: a,
|
|
337
|
+
swapButton: x,
|
|
338
|
+
swapContent: H,
|
|
339
|
+
forceVisible: De,
|
|
339
340
|
autoFillTick: ae
|
|
340
341
|
}) {
|
|
341
|
-
var
|
|
342
|
-
const
|
|
343
|
-
|
|
344
|
-
const t =
|
|
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;
|
|
345
346
|
if (!t || t.hasAttribute("aria-label")) return;
|
|
346
|
-
t.id || (t.id = `${
|
|
347
|
-
const r = t.tagName === "BUTTON" ? `${
|
|
347
|
+
t.id || (t.id = `${z}-control`);
|
|
348
|
+
const r = t.tagName === "BUTTON" ? `${z} ${t.id}` : z;
|
|
348
349
|
t.getAttribute("aria-labelledby") !== r && t.setAttribute("aria-labelledby", r);
|
|
349
350
|
});
|
|
350
|
-
const
|
|
351
|
-
|
|
352
|
-
const t =
|
|
351
|
+
const we = m && !W, ke = L(null);
|
|
352
|
+
re(() => {
|
|
353
|
+
const t = ke.current;
|
|
353
354
|
if (!t) return;
|
|
354
|
-
if (!
|
|
355
|
+
if (!we) {
|
|
355
356
|
t.removeAttribute("inert");
|
|
356
357
|
return;
|
|
357
358
|
}
|
|
358
359
|
const r = typeof document < "u" ? document.activeElement : null;
|
|
359
360
|
r instanceof HTMLElement && t.contains(r) && r.blur(), t.setAttribute("inert", "");
|
|
360
|
-
}, [
|
|
361
|
-
const
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
361
|
+
}, [we, ae]);
|
|
362
|
+
const G = e.field, _e = Ee(
|
|
363
|
+
(t) => {
|
|
364
|
+
m || p(G, t);
|
|
365
|
+
},
|
|
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,
|
|
369
376
|
field: e,
|
|
370
|
-
value:
|
|
371
|
-
relations:
|
|
372
|
-
collection:
|
|
373
|
-
itemId:
|
|
377
|
+
value: u[e.field],
|
|
378
|
+
relations: f,
|
|
379
|
+
collection: o,
|
|
380
|
+
itemId: l,
|
|
374
381
|
openRelated: s == null ? void 0 : s.openRelated
|
|
375
|
-
}),
|
|
376
|
-
async function
|
|
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() {
|
|
377
384
|
var t;
|
|
378
|
-
if (
|
|
379
|
-
|
|
385
|
+
if (Q.perField) return Ve();
|
|
386
|
+
V(!0);
|
|
380
387
|
try {
|
|
381
|
-
const r = await
|
|
382
|
-
|
|
383
|
-
collection:
|
|
384
|
-
item_id:
|
|
388
|
+
const r = await ie.request(
|
|
389
|
+
xe("/ai/generate", {
|
|
390
|
+
collection: o,
|
|
391
|
+
item_id: l !== "new" ? l : void 0,
|
|
385
392
|
field: e.field
|
|
386
393
|
})
|
|
387
394
|
);
|
|
388
|
-
((t = r.data) == null ? void 0 : t.value) != null &&
|
|
395
|
+
((t = r.data) == null ? void 0 : t.value) != null && p(e.field, r.data.value);
|
|
389
396
|
} catch {
|
|
390
397
|
} finally {
|
|
391
|
-
|
|
398
|
+
V(!1);
|
|
392
399
|
}
|
|
393
400
|
}
|
|
394
|
-
async function
|
|
395
|
-
var r,
|
|
401
|
+
async function Ve() {
|
|
402
|
+
var r, h, k, j, T, F;
|
|
396
403
|
const t = {};
|
|
397
|
-
for (const
|
|
398
|
-
|
|
404
|
+
for (const v of ((r = wt(e._overrides)) == null ? void 0 : r.tokens) ?? []) v in u && (t[v] = u[v]);
|
|
405
|
+
V(!0);
|
|
399
406
|
try {
|
|
400
|
-
const
|
|
401
|
-
|
|
402
|
-
collection:
|
|
407
|
+
const v = await ie.request(
|
|
408
|
+
xe("/ai/field-fill", {
|
|
409
|
+
collection: o,
|
|
403
410
|
layout_id: (s == null ? void 0 : s.layoutId) ?? null,
|
|
404
411
|
field: e.field,
|
|
405
|
-
item_id:
|
|
412
|
+
item_id: l && l !== "new" ? l : null,
|
|
406
413
|
values: t
|
|
407
414
|
})
|
|
408
|
-
),
|
|
409
|
-
typeof
|
|
410
|
-
} catch (
|
|
411
|
-
const
|
|
412
|
-
K.error(((
|
|
415
|
+
), _ = (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)`);
|
|
417
|
+
} catch (v) {
|
|
418
|
+
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");
|
|
413
420
|
} finally {
|
|
414
|
-
|
|
421
|
+
V(!1);
|
|
415
422
|
}
|
|
416
423
|
}
|
|
417
|
-
const
|
|
418
|
-
const r =
|
|
419
|
-
(
|
|
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
|
|
420
427
|
);
|
|
421
428
|
if (!r) return [];
|
|
422
429
|
if (r.junction_field) return [{ rule: t, rel: r }];
|
|
423
|
-
const
|
|
424
|
-
(
|
|
430
|
+
const h = f.find(
|
|
431
|
+
(k) => k.many_collection === r.many_collection && k.id !== r.id
|
|
425
432
|
);
|
|
426
|
-
return
|
|
427
|
-
}),
|
|
428
|
-
queries:
|
|
429
|
-
queryKey: ["m2m-items", t.many_collection, t.many_field,
|
|
430
|
-
queryFn: () =>
|
|
431
|
-
|
|
432
|
-
filter: JSON.stringify({ [t.many_field]: { _eq:
|
|
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 }) => ({
|
|
436
|
+
queryKey: ["m2m-items", t.many_collection, t.many_field, l],
|
|
437
|
+
queryFn: () => ie.request(
|
|
438
|
+
U(`/items/${t.many_collection}`, {
|
|
439
|
+
filter: JSON.stringify({ [t.many_field]: { _eq: l } }),
|
|
433
440
|
limit: 200,
|
|
434
441
|
fields: `id,${t.junction_field}`
|
|
435
442
|
})
|
|
436
443
|
).then((r) => r.data ?? []),
|
|
437
|
-
enabled: !!
|
|
444
|
+
enabled: !!l && l !== "new",
|
|
438
445
|
staleTime: 3e4
|
|
439
446
|
}))
|
|
440
|
-
}),
|
|
441
|
-
|
|
442
|
-
var
|
|
443
|
-
const
|
|
447
|
+
}), Ge = Object.fromEntries(
|
|
448
|
+
Le.map(({ rule: t, rel: r }, h) => {
|
|
449
|
+
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();
|
|
444
451
|
return [
|
|
445
452
|
t.parent_field,
|
|
446
|
-
(((
|
|
453
|
+
(((T = ze[h]) == null ? void 0 : T.data) ?? []).filter((F) => !j.has(F.id)).map((F) => F[r.junction_field])
|
|
447
454
|
];
|
|
448
455
|
})
|
|
449
|
-
),
|
|
450
|
-
if (!
|
|
456
|
+
), Y = Nt()[e.field] ?? [];
|
|
457
|
+
if (!De && (!b || !e.layout_assigned && (e.hidden || jt.has(e.field))))
|
|
451
458
|
return null;
|
|
452
|
-
const
|
|
453
|
-
|
|
454
|
-
const
|
|
455
|
-
const t =
|
|
456
|
-
(
|
|
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 = (() => {
|
|
462
|
+
const t = f.find(
|
|
463
|
+
(h) => h.one_collection === o && h.one_field === e.field
|
|
457
464
|
);
|
|
458
465
|
if (!t) return null;
|
|
459
466
|
if (t.junction_field) return t;
|
|
460
|
-
const r =
|
|
461
|
-
(
|
|
467
|
+
const r = f.find(
|
|
468
|
+
(h) => h.many_collection === t.many_collection && h.id !== t.id
|
|
462
469
|
);
|
|
463
470
|
return r ? { ...t, junction_field: r.many_field } : null;
|
|
464
|
-
})(),
|
|
471
|
+
})(), ce = w ? null : f.find((t) => t.many_collection === o && t.many_field === e.field) ?? null, ue = w ? f.find(
|
|
465
472
|
(t) => t.many_collection === w.many_collection && t.many_field === w.junction_field && t.id !== w.id
|
|
466
|
-
) ?? null : null, M = w ? w.one_field ?? `${w.many_collection}.${w.junction_field}` : null,
|
|
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([
|
|
467
474
|
"m2m-items",
|
|
468
475
|
w.many_collection,
|
|
469
476
|
w.many_field,
|
|
470
|
-
|
|
471
|
-
]) ?? []).map((t) => t[w.junction_field]) : [],
|
|
477
|
+
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) => {
|
|
472
479
|
var r;
|
|
473
|
-
return ((
|
|
474
|
-
},
|
|
475
|
-
rules:
|
|
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,
|
|
476
483
|
// A parent whose value THIS field's own pick derived must not narrow this
|
|
477
484
|
// field's options — otherwise picking a region locks the region picker
|
|
478
485
|
// into the zone the pick itself filled, and cross-zone changes read as
|
|
479
486
|
// "No results".
|
|
480
487
|
skipParent: (t) => {
|
|
481
488
|
var r;
|
|
482
|
-
return ((r =
|
|
489
|
+
return ((r = g == null ? void 0 : g.getDerivedOrigin) == null ? void 0 : r.call(g, t)) === e.field;
|
|
483
490
|
},
|
|
484
491
|
parentValue: (t) => {
|
|
485
|
-
if (
|
|
486
|
-
const r =
|
|
492
|
+
if (u[t] != null) return u[t];
|
|
493
|
+
const r = f.find((v) => v.one_collection === o && v.one_field === t);
|
|
487
494
|
if (!r) return null;
|
|
488
|
-
let
|
|
489
|
-
if (!
|
|
490
|
-
const
|
|
491
|
-
(
|
|
495
|
+
let h = r;
|
|
496
|
+
if (!h.junction_field) {
|
|
497
|
+
const v = f.find(
|
|
498
|
+
(_) => _.many_collection === r.many_collection && _.id !== r.id
|
|
492
499
|
);
|
|
493
|
-
if (
|
|
500
|
+
if (v != null && v.many_field) h = { ...r, junction_field: v.many_field };
|
|
494
501
|
else return null;
|
|
495
502
|
}
|
|
496
|
-
const
|
|
497
|
-
return
|
|
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)))];
|
|
504
|
+
return F.length === 0 ? null : F.length === 1 ? F[0] : F;
|
|
498
505
|
},
|
|
499
506
|
parentOptionFilter: (t) => {
|
|
500
|
-
var
|
|
501
|
-
const r = (
|
|
502
|
-
return r ?
|
|
507
|
+
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;
|
|
503
510
|
}
|
|
504
|
-
}), O =
|
|
505
|
-
function
|
|
506
|
-
|
|
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;
|
|
514
|
+
if (t && t.src === e) return t.value;
|
|
515
|
+
const r = { ...e, readonly: !0 };
|
|
516
|
+
return Fe.current = { src: e, value: r }, r;
|
|
517
|
+
}
|
|
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;
|
|
521
|
+
const h = {
|
|
522
|
+
labels: B,
|
|
523
|
+
keys: me,
|
|
524
|
+
onClear: (k) => p(k, null)
|
|
525
|
+
};
|
|
526
|
+
return Ne.current = { sig: t, onChange: p, value: h }, h;
|
|
527
|
+
}
|
|
528
|
+
function rt() {
|
|
529
|
+
for (const t of me) {
|
|
507
530
|
const r = document.querySelector(`[data-field="${t}"]`);
|
|
508
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(() => {
|
|
509
532
|
r.style.boxShadow = "none", setTimeout(() => {
|
|
@@ -512,96 +535,96 @@ function kn({
|
|
|
512
535
|
}, 900));
|
|
513
536
|
}
|
|
514
537
|
}
|
|
515
|
-
const
|
|
538
|
+
const lt = () => {
|
|
516
539
|
if (w && M) {
|
|
517
|
-
for (const r of
|
|
518
|
-
const t =
|
|
540
|
+
for (const r of $e) g == null || g.unstageLink(M, r);
|
|
541
|
+
const t = ye.getQueryData([
|
|
519
542
|
"m2m-items",
|
|
520
543
|
w.many_collection,
|
|
521
544
|
w.many_field,
|
|
522
|
-
|
|
545
|
+
l
|
|
523
546
|
]) ?? [];
|
|
524
|
-
for (const r of t)
|
|
547
|
+
for (const r of t) g == null || g.stageUnlink(M, r.id);
|
|
525
548
|
} else
|
|
526
|
-
|
|
549
|
+
p(e.field, null);
|
|
527
550
|
};
|
|
528
551
|
return (
|
|
529
552
|
// biome-ignore lint/a11y/noStaticElementInteractions: the wrapper only hosts the field context menu (right-click / Shift+F10); the inputs inside stay the controls
|
|
530
|
-
/* @__PURE__ */
|
|
553
|
+
/* @__PURE__ */ c(
|
|
531
554
|
"div",
|
|
532
555
|
{
|
|
533
|
-
ref:
|
|
556
|
+
ref: oe,
|
|
534
557
|
"data-field": e.field,
|
|
535
|
-
"data-field-collection":
|
|
558
|
+
"data-field-collection": o,
|
|
536
559
|
"data-field-interface": e.interface ?? void 0,
|
|
537
|
-
"data-autofill-check":
|
|
560
|
+
"data-autofill-check": se ? "" : void 0,
|
|
538
561
|
className: P(
|
|
539
562
|
"group/fieldrow space-y-1.5",
|
|
540
|
-
|
|
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"
|
|
541
564
|
),
|
|
542
|
-
onContextMenu:
|
|
543
|
-
onKeyDown:
|
|
544
|
-
onFocusCapture:
|
|
565
|
+
onContextMenu: Be,
|
|
566
|
+
onKeyDown: Ke,
|
|
567
|
+
onFocusCapture: q.onFocusCapture,
|
|
545
568
|
children: [
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
569
|
+
Ue,
|
|
570
|
+
A.length > 0 && /* @__PURE__ */ n(
|
|
571
|
+
Mt,
|
|
549
572
|
{
|
|
550
|
-
cascadeRules:
|
|
573
|
+
cascadeRules: A,
|
|
551
574
|
cascadeFilter: O,
|
|
552
|
-
currentValue:
|
|
553
|
-
relatedCollection:
|
|
554
|
-
missingRequiredParents:
|
|
555
|
-
onClear:
|
|
575
|
+
currentValue: Ze,
|
|
576
|
+
relatedCollection: Ie,
|
|
577
|
+
missingRequiredParents: pe,
|
|
578
|
+
onClear: lt
|
|
556
579
|
}
|
|
557
580
|
),
|
|
558
|
-
(
|
|
559
|
-
|
|
560
|
-
/* @__PURE__ */ n(
|
|
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 }),
|
|
561
584
|
e.required && /* @__PURE__ */ n("span", { className: "ml-0.5 text-destructive", children: "*" }),
|
|
562
|
-
|
|
585
|
+
Vt(e) && /* @__PURE__ */ n(zt, {})
|
|
563
586
|
] }),
|
|
564
|
-
|
|
565
|
-
/* @__PURE__ */ n(
|
|
566
|
-
/* @__PURE__ */ n(
|
|
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 }) })
|
|
567
590
|
] }) }),
|
|
568
|
-
!
|
|
569
|
-
|
|
591
|
+
!E && l && l !== "new" && /* @__PURE__ */ n(
|
|
592
|
+
sn,
|
|
570
593
|
{
|
|
571
|
-
collection:
|
|
572
|
-
itemId:
|
|
594
|
+
collection: o,
|
|
595
|
+
itemId: l,
|
|
573
596
|
field: e.field,
|
|
574
|
-
onRestore: e.readonly ? void 0 : (t) =>
|
|
597
|
+
onRestore: e.readonly ? void 0 : (t) => p(e.field, t)
|
|
575
598
|
}
|
|
576
599
|
),
|
|
577
|
-
!
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
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,
|
|
581
604
|
{
|
|
582
|
-
collection:
|
|
583
|
-
itemId:
|
|
605
|
+
collection: o,
|
|
606
|
+
itemId: l,
|
|
584
607
|
field: e.field,
|
|
585
|
-
label:
|
|
586
|
-
onFill: (t) =>
|
|
608
|
+
label: S || he(e.field),
|
|
609
|
+
onFill: (t) => p(e.field, t)
|
|
587
610
|
}
|
|
588
611
|
),
|
|
589
|
-
!
|
|
612
|
+
!E && Q.show && !(Q.perField && (m || e.readonly)) && /* @__PURE__ */ c(
|
|
590
613
|
"button",
|
|
591
614
|
{
|
|
592
615
|
type: "button",
|
|
593
|
-
onClick:
|
|
594
|
-
disabled:
|
|
595
|
-
"data-ai-fill":
|
|
616
|
+
onClick: We,
|
|
617
|
+
disabled: be,
|
|
618
|
+
"data-ai-fill": Q.perField ? e.field : void 0,
|
|
596
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",
|
|
597
620
|
title: "Generate with AI",
|
|
598
621
|
children: [
|
|
599
|
-
|
|
622
|
+
be ? /* @__PURE__ */ n(st, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ n(dt, { className: "h-3 w-3" }),
|
|
600
623
|
"AI"
|
|
601
624
|
]
|
|
602
625
|
}
|
|
603
626
|
),
|
|
604
|
-
|
|
627
|
+
se && /* @__PURE__ */ n(
|
|
605
628
|
"span",
|
|
606
629
|
{
|
|
607
630
|
"data-tip": "People often change what the AI read from the document here — check it",
|
|
@@ -609,37 +632,37 @@ function kn({
|
|
|
609
632
|
children: "Check this"
|
|
610
633
|
}
|
|
611
634
|
),
|
|
612
|
-
|
|
613
|
-
|
|
635
|
+
x,
|
|
636
|
+
$ && !m && !e.readonly && /* @__PURE__ */ c(
|
|
614
637
|
"button",
|
|
615
638
|
{
|
|
616
639
|
type: "button",
|
|
617
|
-
onClick: () =>
|
|
618
|
-
disabled:
|
|
640
|
+
onClick: () => $.onApply(u[e.field] ?? null),
|
|
641
|
+
disabled: u[e.field] == null || u[e.field] === "" || $.count === 0,
|
|
619
642
|
"data-apply-to-lines": e.field,
|
|
620
|
-
"data-tip":
|
|
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)",
|
|
621
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",
|
|
622
645
|
children: [
|
|
623
|
-
|
|
646
|
+
$.label ?? "Apply to lines",
|
|
624
647
|
" ↓"
|
|
625
648
|
]
|
|
626
649
|
}
|
|
627
650
|
),
|
|
628
|
-
|
|
629
|
-
/* @__PURE__ */ n(
|
|
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: [
|
|
630
653
|
/* @__PURE__ */ n("span", { className: "h-1.5 w-1.5 rounded-full bg-amber-400 shrink-0" }),
|
|
631
654
|
"addendum"
|
|
632
655
|
] }) }),
|
|
633
|
-
/* @__PURE__ */
|
|
634
|
-
/* @__PURE__ */
|
|
656
|
+
/* @__PURE__ */ c(te, { side: "top", className: "max-w-[220px] text-[12px]", children: [
|
|
657
|
+
/* @__PURE__ */ c("p", { className: "font-medium mb-1", children: [
|
|
635
658
|
"In active addendum",
|
|
636
|
-
|
|
659
|
+
Y.length > 1 ? "s" : "",
|
|
637
660
|
":"
|
|
638
661
|
] }),
|
|
639
|
-
|
|
662
|
+
Y.map((t) => /* @__PURE__ */ c("p", { className: "text-slate-400", children: [
|
|
640
663
|
t.title,
|
|
641
664
|
" ",
|
|
642
|
-
/* @__PURE__ */
|
|
665
|
+
/* @__PURE__ */ c("span", { className: "capitalize", children: [
|
|
643
666
|
"(",
|
|
644
667
|
t.status,
|
|
645
668
|
")"
|
|
@@ -648,108 +671,104 @@ function kn({
|
|
|
648
671
|
] })
|
|
649
672
|
] }) }),
|
|
650
673
|
/* @__PURE__ */ n(
|
|
651
|
-
|
|
674
|
+
At,
|
|
652
675
|
{
|
|
653
|
-
collection:
|
|
676
|
+
collection: o,
|
|
654
677
|
kind: "field",
|
|
655
678
|
name: e.field,
|
|
656
|
-
label:
|
|
679
|
+
label: S
|
|
657
680
|
}
|
|
658
681
|
),
|
|
659
|
-
(m || e.readonly) && D ? /* @__PURE__ */ n(
|
|
660
|
-
/* @__PURE__ */ n(
|
|
661
|
-
/* @__PURE__ */ n(
|
|
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" })
|
|
662
685
|
] }) }) : null,
|
|
663
|
-
|
|
664
|
-
const t = !!O && Object.keys(O).length > 0 &&
|
|
665
|
-
(
|
|
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))
|
|
666
689
|
);
|
|
667
|
-
return /* @__PURE__ */ n(
|
|
668
|
-
/* @__PURE__ */ n(
|
|
690
|
+
return /* @__PURE__ */ n(Z, { delayDuration: 100, children: /* @__PURE__ */ c(I, { children: [
|
|
691
|
+
/* @__PURE__ */ n(ee, { asChild: !0, children: /* @__PURE__ */ n(
|
|
669
692
|
"button",
|
|
670
693
|
{
|
|
671
694
|
type: "button",
|
|
672
|
-
"aria-label": `Show the fields that narrow ${
|
|
673
|
-
onClick:
|
|
695
|
+
"aria-label": `Show the fields that narrow ${S || "this list"}`,
|
|
696
|
+
onClick: rt,
|
|
674
697
|
className: P(
|
|
675
698
|
"inline-flex items-center transition-colors",
|
|
676
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"
|
|
677
700
|
),
|
|
678
|
-
children: /* @__PURE__ */ n(
|
|
701
|
+
children: /* @__PURE__ */ n(ut, { className: "h-3 w-3" })
|
|
679
702
|
}
|
|
680
703
|
) }),
|
|
681
|
-
/* @__PURE__ */ n(
|
|
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` })
|
|
682
705
|
] }) });
|
|
683
706
|
})()
|
|
684
707
|
] }),
|
|
685
|
-
|
|
686
|
-
|
|
708
|
+
q.editor && !m && /* @__PURE__ */ n(
|
|
709
|
+
St,
|
|
687
710
|
{
|
|
688
|
-
editor:
|
|
689
|
-
confirming:
|
|
690
|
-
onConfirm:
|
|
691
|
-
onCancel:
|
|
711
|
+
editor: q.editor,
|
|
712
|
+
confirming: q.confirming,
|
|
713
|
+
onConfirm: q.confirm,
|
|
714
|
+
onCancel: q.cancel
|
|
692
715
|
}
|
|
693
716
|
),
|
|
694
|
-
|
|
717
|
+
H ?? /* @__PURE__ */ n(
|
|
695
718
|
"div",
|
|
696
719
|
{
|
|
697
|
-
ref:
|
|
698
|
-
className: P(m && !
|
|
720
|
+
ref: ge,
|
|
721
|
+
className: P(m && !W && "cursor-not-allowed"),
|
|
699
722
|
"data-tip": (m || e.readonly) && D ? D : void 0,
|
|
700
723
|
onPointerEnter: (m || e.readonly) && D ? s == null ? void 0 : s.onLockHover : void 0,
|
|
701
724
|
children: /* @__PURE__ */ n(
|
|
702
725
|
"div",
|
|
703
726
|
{
|
|
704
|
-
ref:
|
|
727
|
+
ref: ke,
|
|
705
728
|
className: P(
|
|
706
729
|
// A locked FILE field stays interactive: its chips keep the
|
|
707
730
|
// download link and preview click (the component itself hides
|
|
708
731
|
// upload/replace/remove when readonly) — blocking pointer events
|
|
709
732
|
// made attachments unopenable on every locked form (addendum
|
|
710
733
|
// view, terminal states).
|
|
711
|
-
m && !
|
|
734
|
+
m && !W && "pointer-events-none opacity-60",
|
|
712
735
|
// The ring lands with a 2px shake so the eye finds the field;
|
|
713
736
|
// the animation runs once when the class is added.
|
|
714
|
-
|
|
737
|
+
N && "nvr-shake ring-1 ring-red-400 rounded-md",
|
|
715
738
|
ae && "nvr-autofill-glow"
|
|
716
739
|
),
|
|
717
|
-
children:
|
|
718
|
-
|
|
740
|
+
children: E ? /* @__PURE__ */ n(Qt, { field: e, values: u }) : Je ? /* @__PURE__ */ n(
|
|
741
|
+
Ft,
|
|
719
742
|
{
|
|
720
|
-
collection:
|
|
743
|
+
collection: o,
|
|
721
744
|
field: e,
|
|
722
|
-
draft:
|
|
723
|
-
itemId:
|
|
745
|
+
draft: u,
|
|
746
|
+
itemId: l
|
|
724
747
|
}
|
|
725
|
-
) :
|
|
748
|
+
) : y ? y({
|
|
726
749
|
field: e,
|
|
727
|
-
value:
|
|
728
|
-
onChange:
|
|
750
|
+
value: de,
|
|
751
|
+
onChange: _e,
|
|
729
752
|
disabled: m,
|
|
730
|
-
collection:
|
|
731
|
-
itemId:
|
|
732
|
-
relations:
|
|
753
|
+
collection: o,
|
|
754
|
+
itemId: l,
|
|
755
|
+
relations: f,
|
|
733
756
|
cascadeFilter: O,
|
|
734
|
-
unsatisfiedParentLabel:
|
|
735
|
-
requiredParentLabel:
|
|
757
|
+
unsatisfiedParentLabel: et,
|
|
758
|
+
requiredParentLabel: Se
|
|
736
759
|
}) : /* @__PURE__ */ n(
|
|
737
|
-
|
|
760
|
+
qt,
|
|
738
761
|
{
|
|
739
|
-
field: m &&
|
|
740
|
-
value:
|
|
741
|
-
onChange:
|
|
742
|
-
relations:
|
|
743
|
-
collection:
|
|
744
|
-
itemId:
|
|
762
|
+
field: m && W ? tt() : e,
|
|
763
|
+
value: de,
|
|
764
|
+
onChange: _e,
|
|
765
|
+
relations: f,
|
|
766
|
+
collection: o,
|
|
767
|
+
itemId: l,
|
|
745
768
|
cascadeFilter: O,
|
|
746
|
-
requiredParentLabel:
|
|
747
|
-
narrowedBy:
|
|
748
|
-
|
|
749
|
-
keys: Fe,
|
|
750
|
-
onClear: (t) => f(t, null)
|
|
751
|
-
} : void 0,
|
|
752
|
-
onCountChange: y ? (t) => y(e.field, t) : void 0
|
|
769
|
+
requiredParentLabel: Se,
|
|
770
|
+
narrowedBy: B.length > 0 ? nt() : void 0,
|
|
771
|
+
onCountChange: a ? Me : void 0
|
|
753
772
|
}
|
|
754
773
|
)
|
|
755
774
|
},
|
|
@@ -757,11 +776,11 @@ function kn({
|
|
|
757
776
|
)
|
|
758
777
|
}
|
|
759
778
|
),
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
779
|
+
Re && /* @__PURE__ */ n(Yt, { value: u[e.field], config: Re }),
|
|
780
|
+
Ce && /* @__PURE__ */ n(
|
|
781
|
+
Tt,
|
|
763
782
|
{
|
|
764
|
-
change:
|
|
783
|
+
change: Ce,
|
|
765
784
|
onDismiss: () => s == null ? void 0 : s.dismissRemoteChange(e.field),
|
|
766
785
|
onTakeTheirs: s != null && s.takeRemoteChange ? () => {
|
|
767
786
|
var t;
|
|
@@ -773,9 +792,9 @@ function kn({
|
|
|
773
792
|
}
|
|
774
793
|
)
|
|
775
794
|
);
|
|
776
|
-
}
|
|
795
|
+
});
|
|
777
796
|
export {
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
797
|
+
jn as FieldRow,
|
|
798
|
+
En as lineageSummary,
|
|
799
|
+
an as useFieldLineage
|
|
781
800
|
};
|