@nivaro/react 0.2.51 → 0.2.52

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 (117) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +204 -6
  4. package/dist/index.js +442 -439
  5. package/dist/layout-editor.d.ts +80 -0
  6. package/dist/layout-editor.js +11 -0
  7. package/dist/shared/components/ItemEditForm.js +4044 -3866
  8. package/dist/shared/components/RecordDrilldownSheet.js +114 -97
  9. package/dist/shared/components/RecordReadView.js +637 -570
  10. package/dist/shared/components/ai/ExplainButton.js +1 -1
  11. package/dist/shared/components/item-edit/GroupSection.js +489 -466
  12. package/dist/shared/components/item-edit/HeaderBand.js +47 -44
  13. package/dist/shared/components/item-edit/M2MStagingContext.js +3 -3
  14. package/dist/shared/components/item-edit/O2MStagingContext.js +1 -1
  15. package/dist/shared/components/item-edit/RecordGrantTools.js +206 -0
  16. package/dist/shared/components/item-edit/StepsBar.js +49 -43
  17. package/dist/shared/components/item-edit/SummaryPanel.js +1 -1
  18. package/dist/shared/components/item-edit/config-update.js +6 -0
  19. package/dist/shared/components/item-edit/layout-editing-quiet.js +25 -0
  20. package/dist/shared/components/layout-editor/AddPanel.js +301 -0
  21. package/dist/shared/components/layout-editor/DesignNode.js +173 -0
  22. package/dist/shared/components/layout-editor/EditorCanvas.js +52 -0
  23. package/dist/shared/components/layout-editor/EditorTopBar.js +241 -0
  24. package/dist/shared/components/layout-editor/HistoryPanel.js +179 -0
  25. package/dist/shared/components/layout-editor/LayoutEditor.js +393 -0
  26. package/dist/shared/components/layout-editor/LayoutsRail.js +89 -0
  27. package/dist/shared/components/layout-editor/add-target.js +103 -0
  28. package/dist/shared/components/layout-editor/bundle-to-active.js +86 -0
  29. package/dist/shared/components/layout-editor/canvases/PdfCanvas.js +90 -0
  30. package/dist/shared/components/layout-editor/canvases/TableColumnsCanvas.js +246 -0
  31. package/dist/shared/components/layout-editor/collection-meta.js +22 -0
  32. package/dist/shared/components/layout-editor/design-canvas.js +81 -0
  33. package/dist/shared/components/layout-editor/design-context.js +21 -0
  34. package/dist/shared/components/layout-editor/dnd/LayoutDndProvider.js +225 -0
  35. package/dist/shared/components/layout-editor/dnd/collision.js +107 -0
  36. package/dist/shared/components/layout-editor/dnd/node.js +164 -0
  37. package/dist/shared/components/layout-editor/dnd/order.js +122 -0
  38. package/dist/shared/components/layout-editor/editors/DefaultValuesEditor.js +223 -0
  39. package/dist/shared/components/layout-editor/editors/QuickPickerStepsEditor.js +129 -0
  40. package/dist/shared/components/layout-editor/editors/ReadPresentationEditor.js +134 -0
  41. package/dist/shared/components/layout-editor/editors/RecordConditionsEditor.js +249 -0
  42. package/dist/shared/components/layout-editor/editors/RolesPicker.js +77 -0
  43. package/dist/shared/components/layout-editor/editors/cascade-filters.js +556 -0
  44. package/dist/shared/components/layout-editor/editors/cascade-rule-row.js +150 -0
  45. package/dist/shared/components/layout-editor/editors/controls.js +73 -0
  46. package/dist/shared/components/layout-editor/editors/editor-api.js +21 -0
  47. package/dist/shared/components/layout-editor/editors/editor-queries.js +25 -0
  48. package/dist/shared/components/layout-editor/editors/field-default-value.js +131 -0
  49. package/dist/shared/components/layout-editor/editors/grid-presets.js +310 -0
  50. package/dist/shared/components/layout-editor/editors/inline-display.js +157 -0
  51. package/dist/shared/components/layout-editor/editors/layout-picker.js +80 -0
  52. package/dist/shared/components/layout-editor/editors/layout-rows.js +55 -0
  53. package/dist/shared/components/layout-editor/editors/lock-conditions.js +109 -0
  54. package/dist/shared/components/layout-editor/editors/o2m-agg-field.js +25 -0
  55. package/dist/shared/components/layout-editor/editors/pdf-field-config.js +107 -0
  56. package/dist/shared/components/layout-editor/editors/report-widget-config.js +94 -0
  57. package/dist/shared/components/layout-editor/editors/row-rule-check.js +225 -0
  58. package/dist/shared/components/layout-editor/editors/row-rule-row.js +1353 -0
  59. package/dist/shared/components/layout-editor/editors/swap-config.js +245 -0
  60. package/dist/shared/components/layout-editor/focus-buffer.js +32 -0
  61. package/dist/shared/components/layout-editor/host.js +15 -0
  62. package/dist/shared/components/layout-editor/inspector/AdvancedTab.js +296 -0
  63. package/dist/shared/components/layout-editor/inspector/GridTab.js +767 -0
  64. package/dist/shared/components/layout-editor/inspector/GroupInspector.js +456 -0
  65. package/dist/shared/components/layout-editor/inspector/HeaderItemInspector.js +268 -0
  66. package/dist/shared/components/layout-editor/inspector/Inspector.js +332 -0
  67. package/dist/shared/components/layout-editor/inspector/LookTab.js +310 -0
  68. package/dist/shared/components/layout-editor/inspector/PickerTab.js +333 -0
  69. package/dist/shared/components/layout-editor/inspector/RulesTab.js +323 -0
  70. package/dist/shared/components/layout-editor/inspector/SlotInspector.js +179 -0
  71. package/dist/shared/components/layout-editor/inspector/SubtitleInspector.js +154 -0
  72. package/dist/shared/components/layout-editor/inspector/WidgetInspector.js +262 -0
  73. package/dist/shared/components/layout-editor/inspector/applies.js +27 -0
  74. package/dist/shared/components/layout-editor/inspector/field-context.js +134 -0
  75. package/dist/shared/components/layout-editor/inspector/interfaces.js +126 -0
  76. package/dist/shared/components/layout-editor/inspector/kit.js +595 -0
  77. package/dist/shared/components/layout-editor/inspector/model.js +307 -0
  78. package/dist/shared/components/layout-editor/overview/OverviewActions.js +15 -0
  79. package/dist/shared/components/layout-editor/overview/describe-conditions.js +121 -0
  80. package/dist/shared/components/layout-editor/overview/overview-api.js +141 -0
  81. package/dist/shared/components/layout-editor/overview/purpose.js +62 -0
  82. package/dist/shared/components/layout-editor/overview/record-count.js +65 -0
  83. package/dist/shared/components/layout-editor/panel-frame.js +99 -0
  84. package/dist/shared/components/layout-editor/panel-style.js +19 -0
  85. package/dist/shared/components/layout-editor/pickers/field-picker.js +230 -0
  86. package/dist/shared/components/layout-editor/pickers/icon-picker.js +233 -0
  87. package/dist/shared/components/layout-editor/pickers/relation-label.js +34 -0
  88. package/dist/shared/components/layout-editor/pickers/relation-picker.js +136 -0
  89. package/dist/shared/components/layout-editor/record-queries.js +15 -0
  90. package/dist/shared/components/layout-editor/settings/AddendumSection.js +52 -0
  91. package/dist/shared/components/layout-editor/settings/ButtonsSection.js +45 -0
  92. package/dist/shared/components/layout-editor/settings/DefaultsSection.js +67 -0
  93. package/dist/shared/components/layout-editor/settings/FormSettings.js +146 -0
  94. package/dist/shared/components/layout-editor/settings/InheritanceSection.js +37 -0
  95. package/dist/shared/components/layout-editor/settings/LayoutSection.js +70 -0
  96. package/dist/shared/components/layout-editor/settings/PdfSection.js +176 -0
  97. package/dist/shared/components/layout-editor/settings/ReadSection.js +79 -0
  98. package/dist/shared/components/layout-editor/settings/TextSetting.js +55 -0
  99. package/dist/shared/components/layout-editor/settings/ToggleSetting.js +33 -0
  100. package/dist/shared/components/layout-editor/settings/ToolsSection.js +179 -0
  101. package/dist/shared/components/layout-editor/settings/WhoSection.js +213 -0
  102. package/dist/shared/components/layout-editor/settings/controls.js +214 -0
  103. package/dist/shared/components/layout-editor/settings/section-props.js +17 -0
  104. package/dist/shared/components/layout-editor/settings/settings-api.js +151 -0
  105. package/dist/shared/components/layout-editor/settings/settings-registry.js +445 -0
  106. package/dist/shared/components/layout-editor/slot-names.js +20 -0
  107. package/dist/shared/components/layout-editor/summary-pref.js +21 -0
  108. package/dist/shared/components/layout-editor/useLayoutDraft.js +474 -0
  109. package/dist/shared/components/pipeline/relations.js +28 -23
  110. package/dist/shared/components/ui/popover.js +17 -17
  111. package/dist/shared/components/ui/scroll-area.js +38 -0
  112. package/dist/shared/hooks/useRelationOptions.js +60 -0
  113. package/dist/shared/lib/layout-grants.js +9 -0
  114. package/dist/shared/lib/layout-ops.js +348 -0
  115. package/dist/shared/lib/layout-slots.js +11 -7
  116. package/dist/shared/lib/request-gate.js +1 -1
  117. package/package.json +5 -1
@@ -0,0 +1,595 @@
1
+ import { jsx as t, jsxs as d, Fragment as J } from "react/jsx-runtime";
2
+ import { useQuery as R } from "@tanstack/react-query";
3
+ import { Globe2 as j, ChevronRight as _, ChevronDown as $, Check as G, X as U } from "lucide-react";
4
+ import { createContext as P, useContext as f, useState as g, useRef as I, useEffect as E } from "react";
5
+ import { useNivaroClient as K } from "../../../context.js";
6
+ import { get as M } from "../../../lib/commands.js";
7
+ import { cn as m } from "../../../lib/utils.js";
8
+ import { Command as V, CommandInput as Q, CommandList as W, CommandEmpty as X, CommandGroup as Y, CommandItem as z } from "../../ui/command.js";
9
+ import { Popover as H, PopoverTrigger as Z, PopoverContent as ee } from "../../ui/popover.js";
10
+ import { SimpleSelect as te } from "../../ui/SimpleSelect.js";
11
+ import { Switch as ne } from "../../ui/switch.js";
12
+ import { useFocusBuffer as x } from "../focus-buffer.js";
13
+ import { effectText as q, labelText as ae, inputBase as v, segOption as re, segTrack as le, groupTitle as L } from "../panel-style.js";
14
+ const N = P(null);
15
+ function se() {
16
+ const e = f(N);
17
+ if (!e) throw new Error("Inspector parts render inside <Inspector>");
18
+ return e;
19
+ }
20
+ const C = P(null);
21
+ function Oe(e, o) {
22
+ var n;
23
+ const i = f(C), r = (n = i == null ? void 0 : i.pending) == null ? void 0 : n.values;
24
+ return r && e in r ? r[e] : o;
25
+ }
26
+ function oe() {
27
+ const e = f(C), o = K(), i = e == null ? void 0 : e.pending, { data: r, isLoading: n } = R({
28
+ queryKey: ["layout-editor", "field-impact", e == null ? void 0 : e.collection, e == null ? void 0 : e.field],
29
+ queryFn: () => o.request(
30
+ M(`/data-model/${e == null ? void 0 : e.collection}/fields/${encodeURIComponent((e == null ? void 0 : e.field) ?? "")}/impact`)
31
+ ).then((s) => s.data ?? []),
32
+ enabled: !!i && !!e,
33
+ staleTime: 6e4
34
+ });
35
+ if (!e || !i) return null;
36
+ const a = [
37
+ ...new Set((r ?? []).filter((s) => s.source === "layout").map((s) => s.label))
38
+ ], c = [
39
+ ...new Set((r ?? []).filter((s) => s.source !== "layout").map((s) => s.label))
40
+ ], l = a.slice(0, 8);
41
+ return /* @__PURE__ */ d(
42
+ "div",
43
+ {
44
+ "data-setting": "inspector.global_confirm",
45
+ "data-global-confirm": "",
46
+ className: "mt-1.5 space-y-2 rounded-md border border-amber-300 bg-amber-50 p-2.5 text-[12px] text-amber-900 dark:border-amber-700/60 dark:bg-amber-950/40 dark:text-amber-100",
47
+ children: [
48
+ /* @__PURE__ */ d("p", { className: "font-medium", children: [
49
+ "This changes ",
50
+ e.fieldLabel,
51
+ " on every form that shows it, not just this one."
52
+ ] }),
53
+ i.labels.length > 1 && /* @__PURE__ */ t("ul", { "data-global-changes": "", className: "list-disc space-y-0.5 pl-4 text-[11px]", children: i.labels.map((s) => /* @__PURE__ */ t("li", { children: s }, s)) }),
54
+ n ? /* @__PURE__ */ d("p", { className: "text-[11px] opacity-80", children: [
55
+ "Finding where ",
56
+ e.fieldLabel,
57
+ " is used…"
58
+ ] }) : /* @__PURE__ */ d("div", { className: "space-y-1 text-[11px]", children: [
59
+ l.length > 0 && /* @__PURE__ */ d("p", { children: [
60
+ "Forms of ",
61
+ e.collectionLabel,
62
+ ": ",
63
+ l.join(", "),
64
+ a.length > l.length && ` and ${a.length - l.length} more`
65
+ ] }),
66
+ /* @__PURE__ */ d("p", { children: [
67
+ "Also the ",
68
+ e.collectionLabel,
69
+ " list and any API reader of this field."
70
+ ] }),
71
+ c.length > 0 && /* @__PURE__ */ d("p", { className: "opacity-80", children: [
72
+ "Other references: ",
73
+ c.slice(0, 5).join(", "),
74
+ c.length > 5 && ` and ${c.length - 5} more`
75
+ ] })
76
+ ] }),
77
+ /* @__PURE__ */ t("p", { className: "text-[11px] opacity-80", children: "Undo does not reverse this." }),
78
+ e.error && /* @__PURE__ */ t("p", { className: "text-[11px] text-red-700 dark:text-red-300", children: e.error }),
79
+ /* @__PURE__ */ d("div", { className: "flex gap-2", children: [
80
+ /* @__PURE__ */ t(
81
+ "button",
82
+ {
83
+ type: "button",
84
+ "data-global-save": "",
85
+ disabled: e.saving,
86
+ onClick: () => e.confirm(),
87
+ className: "rounded-md bg-nvr-cyan px-2.5 py-1 text-[12px] font-medium text-nvr-navy hover:bg-[#00b8e0] disabled:opacity-40",
88
+ children: e.saving ? "Saving…" : "Save for every form"
89
+ }
90
+ ),
91
+ /* @__PURE__ */ t(
92
+ "button",
93
+ {
94
+ type: "button",
95
+ "data-global-cancel": "",
96
+ onClick: () => e.cancel(),
97
+ className: "rounded-md px-2.5 py-1 text-[12px] text-amber-900 hover:bg-amber-100 dark:text-amber-100 dark:hover:bg-amber-900/40",
98
+ children: "Cancel"
99
+ }
100
+ )
101
+ ] })
102
+ ]
103
+ }
104
+ );
105
+ }
106
+ function ie({ scope: e }) {
107
+ return e === "field" ? /* @__PURE__ */ d(
108
+ "span",
109
+ {
110
+ "data-scope": "field",
111
+ "data-tip": "Saved on the field itself: every form that shows this field changes",
112
+ className: "inline-flex shrink-0 items-center gap-1 text-[11px] font-medium text-amber-700 dark:text-amber-300",
113
+ children: [
114
+ /* @__PURE__ */ t(j, { className: "h-3 w-3" }),
115
+ "Every form"
116
+ ]
117
+ }
118
+ ) : /* @__PURE__ */ t("span", { "data-scope": "form", className: "sr-only", children: "This form only" });
119
+ }
120
+ function Te({ field: e }) {
121
+ return /* @__PURE__ */ t("p", { "data-scope-legend": "", className: q, children: e ? /* @__PURE__ */ d(J, { children: [
122
+ "Changes here apply to this form only, except settings marked",
123
+ " ",
124
+ /* @__PURE__ */ d("span", { className: "inline-flex items-center gap-1 whitespace-nowrap font-medium text-amber-700 dark:text-amber-300", children: [
125
+ /* @__PURE__ */ t(j, { className: "h-3 w-3" }),
126
+ "Every form"
127
+ ] }),
128
+ "."
129
+ ] }) : "Changes here apply to this form only." });
130
+ }
131
+ const ce = "Enforced on the default form only";
132
+ function de({ className: e }) {
133
+ return se().defaultForm ? null : /* @__PURE__ */ t(
134
+ "p",
135
+ {
136
+ "data-setting": "inspector.enforcement_note",
137
+ "data-enforcement": "",
138
+ className: m("text-[12px] leading-snug text-amber-700 dark:text-amber-300", e),
139
+ "data-tip": "The server applies this from the active grouped layout. On this form it only works in the browser.",
140
+ children: ce
141
+ }
142
+ );
143
+ }
144
+ function ue({
145
+ k: e,
146
+ label: o,
147
+ effect: i,
148
+ scope: r = "form",
149
+ enforced: n,
150
+ inline: a,
151
+ confirmAt: c,
152
+ children: l,
153
+ className: s
154
+ }) {
155
+ var p;
156
+ const u = f(C);
157
+ return /* @__PURE__ */ d("div", { "data-setting": e, "data-setting-row": "", className: m("space-y-1.5", s), children: [
158
+ /* @__PURE__ */ d("div", { className: "flex min-h-5 items-center justify-between gap-3", children: [
159
+ /* @__PURE__ */ d("span", { className: "flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5", children: [
160
+ /* @__PURE__ */ t("span", { className: ae, children: o }),
161
+ /* @__PURE__ */ t(ie, { scope: r })
162
+ ] }),
163
+ a && /* @__PURE__ */ t("span", { className: "flex shrink-0 items-center", children: l })
164
+ ] }),
165
+ !a && l,
166
+ /* @__PURE__ */ t("p", { "data-effect": "", className: q, children: i }),
167
+ n && /* @__PURE__ */ t(de, {}),
168
+ r === "field" && ((p = u == null ? void 0 : u.pending) == null ? void 0 : p.key) === (c ?? e) && /* @__PURE__ */ t(oe, {})
169
+ ] });
170
+ }
171
+ function Ie({
172
+ k: e,
173
+ label: o,
174
+ effect: i,
175
+ scope: r,
176
+ enforced: n,
177
+ checked: a,
178
+ onChange: c,
179
+ disabled: l,
180
+ confirmAt: s
181
+ }) {
182
+ return /* @__PURE__ */ t(
183
+ ue,
184
+ {
185
+ k: e,
186
+ label: o,
187
+ effect: i,
188
+ scope: r,
189
+ enforced: n,
190
+ confirmAt: s,
191
+ inline: !0,
192
+ children: /* @__PURE__ */ t(
193
+ ne,
194
+ {
195
+ checked: a,
196
+ disabled: l,
197
+ onCheckedChange: c,
198
+ "aria-label": typeof o == "string" ? o : void 0,
199
+ className: "h-[18px] w-8 border-0 data-[state=checked]:bg-nvr-cyan data-[state=unchecked]:bg-slate-300 dark:data-[state=unchecked]:bg-slate-600 [&>span]:mx-0.5 [&>span]:h-3.5 [&>span]:w-3.5 [&>span]:bg-white [&>span]:shadow-sm [&>span]:data-[state=checked]:translate-x-3.5"
200
+ }
201
+ )
202
+ }
203
+ );
204
+ }
205
+ const A = v;
206
+ function me({
207
+ value: e,
208
+ onChange: o,
209
+ placeholder: i,
210
+ mono: r,
211
+ disabled: n,
212
+ type: a = "text",
213
+ ariaLabel: c
214
+ }) {
215
+ const l = f(N), s = x(e, () => l == null ? void 0 : l.flush());
216
+ return /* @__PURE__ */ t(
217
+ "input",
218
+ {
219
+ type: a,
220
+ value: s.value,
221
+ disabled: n,
222
+ "aria-label": c,
223
+ placeholder: i,
224
+ onChange: (u) => {
225
+ s.set(u.target.value), o(u.target.value);
226
+ },
227
+ onKeyDown: (u) => {
228
+ u.key === "Enter" && (l == null || l.flush());
229
+ },
230
+ ...s.props,
231
+ className: m(A, r && "font-mono")
232
+ }
233
+ );
234
+ }
235
+ function Ee({
236
+ value: e,
237
+ onChange: o,
238
+ ariaLabel: i,
239
+ rows: r = 4
240
+ }) {
241
+ const n = f(N), a = x(e, () => n == null ? void 0 : n.flush());
242
+ return /* @__PURE__ */ t(
243
+ "textarea",
244
+ {
245
+ "aria-label": i,
246
+ rows: r,
247
+ value: a.value,
248
+ onChange: (c) => {
249
+ a.set(c.target.value), o(c.target.value);
250
+ },
251
+ ...a.props,
252
+ className: m(v, "h-auto py-1.5 leading-snug")
253
+ }
254
+ );
255
+ }
256
+ function Le({
257
+ value: e,
258
+ children: o,
259
+ className: i
260
+ }) {
261
+ const r = f(N), n = x(e, () => r == null ? void 0 : r.flush());
262
+ return /* @__PURE__ */ t(
263
+ "div",
264
+ {
265
+ className: i,
266
+ ...n.props,
267
+ onKeyDownCapture: (a) => {
268
+ a.key === "Enter" && a.target.tagName === "INPUT" && (r == null || r.flush());
269
+ },
270
+ children: o(n.value, (a) => (n.set(a), a))
271
+ }
272
+ );
273
+ }
274
+ function Fe({
275
+ value: e,
276
+ onCommit: o,
277
+ placeholder: i,
278
+ mono: r,
279
+ ariaLabel: n
280
+ }) {
281
+ const a = x(e);
282
+ return /* @__PURE__ */ t(
283
+ "input",
284
+ {
285
+ value: a.value,
286
+ "aria-label": n,
287
+ placeholder: i,
288
+ onChange: (c) => {
289
+ a.set(c.target.value), o(c.target.value);
290
+ },
291
+ ...a.props,
292
+ className: m(A, r && "font-mono")
293
+ }
294
+ );
295
+ }
296
+ function je({
297
+ value: e,
298
+ options: o,
299
+ onChange: i,
300
+ disabled: r
301
+ }) {
302
+ return /* @__PURE__ */ t("div", { className: le(o.length), children: o.map((n) => /* @__PURE__ */ t(
303
+ "button",
304
+ {
305
+ type: "button",
306
+ "aria-pressed": n.value === e,
307
+ disabled: r,
308
+ "data-tip": n.tip,
309
+ onClick: () => i(n.value),
310
+ className: re(n.value === e),
311
+ children: n.label
312
+ },
313
+ n.value
314
+ )) });
315
+ }
316
+ function F({
317
+ value: e,
318
+ options: o,
319
+ onChange: i,
320
+ ariaLabel: r,
321
+ disabled: n,
322
+ unknownLabel: a = (c) => c
323
+ }) {
324
+ const c = e && !o.some((l) => l.value === e) ? [...o, { value: e, label: a(e) }] : o;
325
+ return /* @__PURE__ */ t(
326
+ te,
327
+ {
328
+ value: e,
329
+ onChange: i,
330
+ options: c,
331
+ ariaLabel: r,
332
+ disabled: n,
333
+ className: m(v, "focus:ring-0 focus:ring-offset-0")
334
+ }
335
+ );
336
+ }
337
+ function Pe({
338
+ value: e,
339
+ onCommit: o,
340
+ placeholder: i,
341
+ rows: r = 4,
342
+ validate: n,
343
+ ariaLabel: a
344
+ }) {
345
+ const c = e == null ? "" : JSON.stringify(e, null, 2), [l, s] = g(c), [u, p] = g(null), b = I(!1);
346
+ E(() => {
347
+ b.current || (s(c), p(null));
348
+ }, [c]);
349
+ const w = (h) => {
350
+ const O = h.trim();
351
+ if (!O) return e != null ? { send: void 0 } : { error: null };
352
+ try {
353
+ const y = JSON.parse(O), T = (n == null ? void 0 : n(y)) ?? null;
354
+ return T ? { error: T } : JSON.stringify(y) !== JSON.stringify(e) ? { send: y } : { error: null };
355
+ } catch {
356
+ return { error: "Not valid JSON — nothing saved" };
357
+ }
358
+ }, D = () => {
359
+ const h = w(l);
360
+ "send" in h ? (p(null), o(h.send)) : p(h.error);
361
+ }, S = I(() => {
362
+ });
363
+ return S.current = () => {
364
+ if (!b.current) return;
365
+ const h = w(l);
366
+ "send" in h && o(h.send);
367
+ }, E(() => () => S.current(), []), /* @__PURE__ */ d("div", { className: "space-y-1", children: [
368
+ /* @__PURE__ */ t(
369
+ "textarea",
370
+ {
371
+ value: l,
372
+ rows: r,
373
+ "aria-label": a,
374
+ spellCheck: !1,
375
+ placeholder: i,
376
+ onChange: (h) => s(h.target.value),
377
+ onFocus: () => {
378
+ b.current = !0;
379
+ },
380
+ onBlur: () => {
381
+ b.current = !1, D();
382
+ },
383
+ className: m(
384
+ "w-full rounded-md border bg-white px-2.5 py-1.5 font-mono text-[12px] leading-snug text-foreground placeholder:text-slate-400 focus:outline-none dark:bg-background",
385
+ u ? "border-red-400 dark:border-red-500" : "border-slate-200 focus:border-nvr-cyan dark:border-border"
386
+ )
387
+ }
388
+ ),
389
+ u && /* @__PURE__ */ t("p", { className: "text-[12px] text-red-600 dark:text-red-400", children: u })
390
+ ] });
391
+ }
392
+ function qe({
393
+ title: e,
394
+ children: o,
395
+ className: i,
396
+ collapsible: r,
397
+ defaultOpen: n = !1
398
+ }) {
399
+ const [a, c] = g(!r || n);
400
+ return /* @__PURE__ */ d(
401
+ "section",
402
+ {
403
+ className: m(
404
+ "space-y-4 border-t border-slate-100 pt-5 dark:border-border/60",
405
+ r && !a && "space-y-0",
406
+ i
407
+ ),
408
+ children: [
409
+ r ? /* @__PURE__ */ d(
410
+ "button",
411
+ {
412
+ type: "button",
413
+ "aria-expanded": a,
414
+ "data-section-toggle": "",
415
+ onClick: () => c((l) => !l),
416
+ className: m(
417
+ L,
418
+ "-mx-1 flex w-[calc(100%+0.5rem)] items-center gap-1.5 rounded px-1 text-left hover:bg-slate-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/50 dark:hover:bg-muted/60"
419
+ ),
420
+ children: [
421
+ /* @__PURE__ */ t(
422
+ _,
423
+ {
424
+ className: m(
425
+ "h-3.5 w-3.5 shrink-0 text-slate-400 transition-transform duration-150",
426
+ a && "rotate-90"
427
+ )
428
+ }
429
+ ),
430
+ e
431
+ ]
432
+ }
433
+ ) : /* @__PURE__ */ t("h3", { className: L, children: e }),
434
+ /* @__PURE__ */ t("div", { hidden: !a, className: "space-y-5", children: o })
435
+ ]
436
+ }
437
+ );
438
+ }
439
+ function Ae({
440
+ value: e,
441
+ options: o,
442
+ onChange: i,
443
+ placeholder: r = "None selected",
444
+ ariaLabel: n
445
+ }) {
446
+ const [a, c] = g(!1), l = (s) => {
447
+ var u;
448
+ return ((u = o.find((p) => p.value === s)) == null ? void 0 : u.label) ?? s;
449
+ };
450
+ return /* @__PURE__ */ d(H, { open: a, onOpenChange: c, children: [
451
+ /* @__PURE__ */ t(Z, { asChild: !0, children: /* @__PURE__ */ d(
452
+ "button",
453
+ {
454
+ type: "button",
455
+ "aria-label": n,
456
+ className: m(
457
+ v,
458
+ "flex items-center justify-between text-left hover:border-slate-300"
459
+ ),
460
+ children: [
461
+ /* @__PURE__ */ t("span", { className: m("truncate", !e.length && "text-slate-400"), children: e.length ? e.map(l).join(", ") : r }),
462
+ /* @__PURE__ */ t($, { className: "ml-1 h-3.5 w-3.5 shrink-0 text-slate-400" })
463
+ ]
464
+ }
465
+ ) }),
466
+ /* @__PURE__ */ t(ee, { className: "w-64 p-0", align: "start", children: /* @__PURE__ */ d(V, { children: [
467
+ /* @__PURE__ */ t(Q, { placeholder: "Search fields…", className: "h-8 text-[12px]" }),
468
+ /* @__PURE__ */ d(W, { className: "max-h-[240px]", children: [
469
+ /* @__PURE__ */ t(X, { className: "py-3 text-center text-[12px] text-muted-foreground", children: "No fields" }),
470
+ /* @__PURE__ */ t(Y, { children: o.map((s) => {
471
+ const u = e.includes(s.value);
472
+ return /* @__PURE__ */ d(
473
+ z,
474
+ {
475
+ value: `${s.label} ${s.value}`,
476
+ onSelect: () => i(u ? e.filter((p) => p !== s.value) : [...e, s.value]),
477
+ className: "flex items-center gap-2 text-[12px]",
478
+ children: [
479
+ /* @__PURE__ */ t(
480
+ G,
481
+ {
482
+ className: m("h-3 w-3 shrink-0", u ? "opacity-100" : "opacity-0")
483
+ }
484
+ ),
485
+ /* @__PURE__ */ t("span", { className: "flex-1 truncate", children: s.label }),
486
+ /* @__PURE__ */ t("span", { className: "shrink-0 font-mono text-[11px] text-slate-400", children: s.hint ?? s.value })
487
+ ]
488
+ },
489
+ s.value
490
+ );
491
+ }) })
492
+ ] })
493
+ ] }) })
494
+ ] });
495
+ }
496
+ const k = [
497
+ { value: "eq", label: "is" },
498
+ { value: "neq", label: "is not" },
499
+ { value: "nnull", label: "is set" }
500
+ ];
501
+ function Be({
502
+ value: e,
503
+ fields: o,
504
+ onChange: i
505
+ }) {
506
+ const r = (n, a) => i(e.map((c, l) => l === n ? { ...c, ...a } : c));
507
+ return /* @__PURE__ */ d("div", { className: "space-y-1.5", children: [
508
+ e.map((n, a) => {
509
+ const c = k.some((l) => l.value === n.op) ? k : [...k, { value: n.op, label: n.op }];
510
+ return (
511
+ // biome-ignore lint/suspicious/noArrayIndexKey: conditions are positional
512
+ /* @__PURE__ */ d("div", { className: "flex items-center gap-1", "data-condition-row": "", children: [
513
+ /* @__PURE__ */ t("div", { className: "min-w-0 flex-[3]", children: /* @__PURE__ */ t(
514
+ F,
515
+ {
516
+ value: n.field,
517
+ ariaLabel: "Field",
518
+ options: [{ value: "", label: "Field…" }, ...o],
519
+ onChange: (l) => r(a, { field: l })
520
+ }
521
+ ) }),
522
+ /* @__PURE__ */ t("div", { className: "min-w-0 flex-[2]", children: /* @__PURE__ */ t(
523
+ F,
524
+ {
525
+ value: n.op,
526
+ ariaLabel: "Condition",
527
+ options: c,
528
+ onChange: (l) => r(a, l === "nnull" ? { op: l, value: void 0 } : { op: l })
529
+ }
530
+ ) }),
531
+ n.op !== "nnull" && n.op !== "null" && /* @__PURE__ */ t("div", { className: "min-w-0 flex-[2]", children: /* @__PURE__ */ t(
532
+ me,
533
+ {
534
+ value: n.value == null ? "" : String(n.value),
535
+ ariaLabel: "Value",
536
+ placeholder: "value",
537
+ onChange: (l) => r(a, { value: l })
538
+ }
539
+ ) }),
540
+ /* @__PURE__ */ t(
541
+ "button",
542
+ {
543
+ type: "button",
544
+ "aria-label": "Remove condition",
545
+ "data-tip": "Remove condition",
546
+ onClick: () => i(e.filter((l, s) => s !== a)),
547
+ className: "inline-flex h-7 w-7 shrink-0 items-center justify-center rounded text-slate-500 transition-colors hover:bg-slate-100 hover:text-red-600 dark:hover:bg-muted dark:hover:text-red-400",
548
+ children: /* @__PURE__ */ t(U, { className: "h-3.5 w-3.5" })
549
+ }
550
+ )
551
+ ] }, a)
552
+ );
553
+ }),
554
+ /* @__PURE__ */ t(
555
+ "button",
556
+ {
557
+ type: "button",
558
+ onClick: () => i([...e, { field: "", op: "eq", value: "" }]),
559
+ className: B,
560
+ children: "+ Add condition"
561
+ }
562
+ )
563
+ ] });
564
+ }
565
+ const B = "text-[12px] font-medium text-sky-700 hover:underline dark:text-nvr-cyan";
566
+ function De({ onClick: e, children: o }) {
567
+ return /* @__PURE__ */ t("button", { type: "button", onClick: e, className: B, children: o });
568
+ }
569
+ export {
570
+ De as AddButton,
571
+ Le as Buffered,
572
+ k as CONDITION_OPS,
573
+ F as Choice,
574
+ Be as ConditionBuilder,
575
+ ce as DEFAULT_FORM_ONLY,
576
+ Fe as DraftInput,
577
+ de as EnforcementNote,
578
+ Ae as FieldMultiPicker,
579
+ oe as GlobalConfirm,
580
+ C as GlobalWriterContext,
581
+ N as InspectorEnvContext,
582
+ Pe as JsonInput,
583
+ Te as ScopeLegend,
584
+ ie as ScopeTag,
585
+ qe as Section,
586
+ je as Segmented,
587
+ ue as Setting,
588
+ Ee as TextArea,
589
+ me as TextInput,
590
+ Ie as Toggle,
591
+ B as addLinkCls,
592
+ A as inputCls,
593
+ Oe as useGlobalValue,
594
+ se as useInspectorEnv
595
+ };